The parts may not cost as much but you need to take in the Inventory (which costs a lot), Development, Research, the Operating System with its Optimization (My iphone 5s, though having a broken Battery that runs out in like 2 hours, has no Problems in Social Media Apps, Homescreen etc.), "Design" (if you like it), Ecosystem and Build Quality.
I wouldnt say they are overpriced, apple just wants profit. Also, you dont have to buy them.
Edit: The flagship Samsung models (S10, S10+, S20 - when it comes out - Note10 etc.) costs just as much to build and has a very similar retail price, while being just as fast.
I also forgot to say that the Apple APU in iPhones is one of the fastest, or atleast best optimized (hence getting great performance and battery life) on the whole market.