With no disrespect intended, some of the answers to this question are rather amusing and most have partial information, but miss the bigger picture.
There are a number of things to consider.
Apple has a world class processor design team. They are considered the best in the world at what they do.
Apple made the better design decision - because they can. Most existing ARM implementations are very close in design to ARM’s reference designs. They don’t deviate much in terms of performance, etc. By contrast, Apple has designed their own architecture. Their SoCs accommodate larger and more powerful cores. What people fail to recognize is that most workloads are only optimized for single core performance. As an example, web applications that run on Javascript are only leveraging single core. Some algorithms simply cannot be optimized for multiple cores. However, there are some that can. While there is value in having strong multi-core performance, there are few instances outside of benchmarks where this is made evident.
There have been studies which demonstrate the benefits of having fewer fast cores which perform their work then “race to sleep”.
What you seldom read about are thermal limitations. 8 core processors are great for benchmark demonstrations, however, you can see from prolonged tests like those on Anandtech that most Android phones need to throttle down after a rather short period of time. Sadly, some Android manufacturers “cheat” on their benchmarks by checking to see if a known benchmark is running, then disabling the thermal based throttling that would normally occur for non-benchmark applications. The OnePlus 5 is a current example of a vendor continuing this practice even after being publicly shamed for doing so.
Fast Android phones still experience occasional lags. Why? Because Android relies on a method of garbage collection for memory management. There are pros and cons with this approach, but most agree this is a bad choice for a mobile device. The only way to minimize this effect is to ship with significantly more memory than should be needed. That’s why a 2GB iPhone feels perfectly fast and fluid, yet a 6GB Android phone will still get the occasional stutter.
There have been some suggestions that Android is slower because it’s more complicated or because it does more. That is complete nonsense. iOS has a full UNIX based OS under the hood and does all sorts of multi-tasking and interprocess communications behind the scenes. Some people seem to mistake Apple’s imposed user policies with the abilities and complexities of the OS itself. If anything, iPhones are doing more work as all iPhones are fully encrypted. Whereas most Android phones are not encrypted with the most often cited reason for not encrypting is due to performance issues.
Finally, yes, Apple does have the ability to build the silicon to be most optimized for their workloads. This happens in a broad sense with the CPU in terms of the general design. However, you are more likely to see this with things like the image signal processor. That’s how iPhones take bursts of 10 pictures per second without breaking a sweat. Apple also optimizes much of the screen drawing, scrolling, animations, etc. for their Metal API. This is much more efficient than OpenGL. The equivalent, Vulkan is just becoming available on Android and it’s not as mature yet. Further, very few Android users are even using the latest OS release. Going forward, we’re going to see Apple leverage more of their advantage with regard to AI processing.
On a side note, Apple also uses a much higher speed NVMe based storage solution (with a custom controller) than their competitors. This helps makes launching applications much faster for example. There are often videos on YouTube which demonstrate this advantage. Sadly, the people running the tests attribute the speed difference to Apple’s faster CPU… which has nothing to do with storage I/O performance. However, it does contribute to making the iPhone feel faster.