I read an article one that I summarized as Apple Products cost twice as much because they spend 20% more on material.
Part is also you have to pay the engineers who designed it.
Part is people are willing to pay extra for Apple.
To be fair other manufactures flagship phones are very expensive too some even more than iPhone
High quality hardware, huge selection of excellent apps, frequent iOS updates with new features and free to users, works seamlessly with Apple's other products (Macs, iPads, Apple Watch), and excellent support. I'm happy to pay the higher prices because I feel I'm getting exceptional value for my money.
Because people are willing to pay that much. Besides the features and quality that put them in the top tier right along with Samsung, the brand has the same kind of reputation that allows Porsche and BMW to charge a premium.