Apple is a luxury product. It is the best. If they started selling not-the-best, it would tarnish their (well-earned, in my opinion) reputation for always making the best.
I use an Android phone and will freely admit that Apple phones are just better. They have better battery life, brighter and larger displays, better manufacturing (no seams, better materials), much better cameras, faster and better-engineered CPUs, a better app ecosystem, and a whole lot of other stuff (better buying experience, better advertising that contributes to the perception of quality, better post-sale support) that combine for a holistic experience of "better" for users.
The way they make money on used is their 30% cut of all app store revenue. You sell any sort of digital goods, whether Candy crush items, digital music, etc., Apple takes ONE THIRD of that. When you consider the size of Apple's installed base of devices, that ends up being a pretty big number.
Also, Google pays Apple a non-trivial amount of money (widely rumored to be hundreds of millions/year) to be the default search engine on iOS. This amount is so large, it's starting to drag down Google's operating margin (read about "traffic acquisition cost" for google). Yet more money from a bigger base of iPhones.