iPhones are expensive relative to many Android phones for a couple of reasons—first, Apple designs and engineers not only the hardware of each phone, but the software too. Apple crafts and controls the entire user experience. Historically, competitors like Samsung have built the handsets, and used Google’s Android operating system to run them. Carefully integrating software and hardware is more resource intensive, and thus, naturally, raises the price of the phone.
Apple also continues to position the iPhone as a higher-end product, which, while keeping it from being a major player in some major developing markets like India, allows the company to reap much higher profit margins on each phone than its competitors. The gambit has worked, thus far: the iPhone is the most profitable product in modern history.
I’d add another point, though. When you consider everything that goes into the iPhone, and the fact that there are dozens of metals that must be sourced from every corner of the globe, manufactured at scale by hand, each at sometimes a rather high human cost, and that there are scores of highly complex component parts like gyroscopes, accelerometers, multitouch sensors, Gorilla Glass, and incredibly compact and powerful A-series processors, the iPhone is, in another sense, rather inexpensive. It can do more than many 5-year-old computers can, for a fraction of the price.