This is done in order to prevent supply chain attacks. iPhones are used by reporters, government employees, and many who live in countries where their rights aren't protected. If someone maliciously slips in third party hardware, the owner of the phone could be open for attacks that violate their privacy. This could potentially be life threatening.
Hardware must be cryptographically signed in order for the phone to operate. Apple does sell these parts, and also a tool kit that will allow you to do these repairs yourself. Of course, the parts and kit are expensive, so it might be cheaper to head to the Apple Store for any repairs.
I can understand why some might not appreciate the cost and inconvenience, but you have got to hand it to Apple for their security measures.