This just highlights the disconnect between spec sheets and actual user experiences. Since 2007 we've heard how the iPhone is under-specced, yet it's user experience tends to exceed that of much higher specced competitors.
I understand where you are comming from, and I agree with you, but for the sake of arguement let me address whether iphones are underspec
---
Lets name these
Part A) CPU
Part B) GPU
Part C) RAM
Part D) Screen
CPU
Since the iPhone 4s the iPhone has not been under spec in any way on the CPU front, in fact it usually has the fastest cpu around. (iPhone 4s was the 5th generation iphone in 2013 we are now on the 9th generation which is the iPhone 6s and 6s Plus and iphone SE). Some years android has cpu on the flagship Android phones that trade blows with that generation iPhone and in some generations (most of the recent ones) the iPhone blows the android cpus out of the water being 20 to 50% faster.
GPU
Since the iPhone 4s the gpu on iPhones has also been class leading.
RAM
Android phones always have more ram than the iPhones for the flagship Android. They often have more ram than they know how to use. Some of the years Apple underspecs their iphones on the amount of ram they have, but some of them while not as much ram as competing android it has enough ram to not be any downside but not excess ram for the sake of excess ram. Such iPhones I am thinking about are the iPhone 5 (6th generation) and the iPhone 6s (9th generation), the iPhone 5s really did not suffer that much from a ram perspective (aka the 7th generation) but it was starting to get to the point you could make the argument, the iPhone 6 (aka the 8th generation) really needed more ram but the lack of ram did not impair the performance of the task you were doing in the task you were doing the iPhone did as well as android and often better, the lack of ram just made the multitasking capabilities of the iPhone 6 as not as much as it should have been for it caused things like too many tabs in webpages to cause reloads and new retrievals etc.
Too much ram that is not being used has two downsides.
1) It uses more power and thus less battery life. Sure the Soc (CPU and GPU) and the Screen are the biggest power draws but ram is still important to have a big effect on battery life.
2) Excess Ram causes different preferences for the software coders and OS design. Apple uses a different model of how applications use RAM that is more ram efficent but more a pita for software developers this technique is called Reference Counting. Android uses something called automatic Garbage Collection which when the ram is not being used by the program the OS decides that ram is not being used and thus reallocate it. The downside of Garbage Collection is that it sometimes "wastes ram" vs an efficently desgined reference counting program and that it wastes cpus cycles for instead of just relinquishing the ram, you do now a search at every interval whether this ram is being used or not and you are not working on the main task for you are just doing upkeep.
Put another way Reference Counting is like filling up a dumpster and then calling the garbage company once its full. Routine Garbage Collection is like sending a Garbage Truck every so days to all the garbage stops and then dumping sometimes full dumpsters, sometimes empty, and sometimes inbetween.
Thus to summarize number 2, how android does software requires more ram by design, but it also causes lazy programming that sometimes uses excess ram that the software designer should pay attention to, and finally even with the best design android program you are going to be wasting some cpu cycles on garbage collection overhead. While Garbage Collection overhead is not a big deal for most software when you are doing something that is very time sensitive that is measured in microseconds such as certain types of interactive gaming (think VR) or the best audio apps both listening and recording waiting for the program to respond due to the delay of several microseconds every so often by the Garbage Collection overhead can be a very big deal.
(Do note lots of changes in Android 5 and Android 6 are the eventual successor to Android 6 are meant to address these concerns and to lower some of the downsides of garbage collection by doing various tweaks)
So all the nitty gritty for Reference Counting vs Garbage Collection makes the ram situation more complicated for you can't just look at RAM on a spec sheet but instead have to test real world conditions like is the lack of ram causing further delays with more page loads, or more retrieval from emmc storage vs ram, for just having more ram does not always translate into real world performance increases.
Screen
The iPhone 4 (aka the 4th generation) had easily the best screen of its time. It caused screen to be a bigger deal with Android phones that they started investing more money in the screen 2010). Downside of iPhone 4 is that the such an improvement of resolution and the lesser increase of GPU improvement caused some tasks the iPhone 4 did worse on the GPU compared to the iPhone 3GS, so while the screen was so much better sometimes it stuttered.
The iPhone 4s fixed all that and arguably had the best screen at the time. That said in 2011 when the iPhone 4s was out the Samsung Galaxy S2 also had a great screen, and when 2012 came out the Iphone 5 screen was better in some areas and the Galaxy S3 was better in other areas. Note I am using the Samsung Galaxy S series as a reference point for android for most of the time they had the best android screens and they the Galaxy series is one of the best sellers of Android phones.
Since that time (2012 on, but definately 2013 on) android has a lot of good screens that are arguably better than the iPhone but even in the high end space there are also a lot of mediocre and average screens that the iPhone beats, but there is at least one or two android phones that have a superior screen to the iPhone. The iPhone is still awesome, but lets use an analogy of a high school test to help explain it. The iPhone of various models it is like getting an A on a test or a 90 and iPhones consistently score a 90 of each various generation years, but some android phones are like an A+ lets say 95, and some are an A++ 97 to a 100. That said even in the high end android phone space a lot of android high end phones are 80 to 90 and 80 to 95 on their test scores.
In other words on the screen front since 2013 iPhones have very good screens but not the best, and from 2010 to 2012 iPhones has the best screens or were tied with the best androids.
-----
In conclusion about the specs of Android vs Apple
So if you read all of that, you will see that I made the argument that iPhones have never been underspeced, and even when androids have better specs it is not necessary all 4 categories I referenced (CPU, GPU, Ram, Screen) but often just 1 or 2 of the categories and even in those 1 or 2 categories the iPhones did not suck it is just in some thing Android was just slightly better.
I will argue by combining good specs in those 4 things as well as having complete control over the OS to optimizes the best performance of those 4 categories allows Apple to deliver a superior performance to Android overall.
-----
That said I am an android fanboy and you will not pry my android phones from my fingers. The only way you can separate my android phone from my body is to remove my fingers for my fingers are attached to my android devices.
I am an android fanboy but I can also ecognize the good things Apples do with their phones. I personally prefer android over ios not because of the harder, but because I like the freedom and flexibility that I can get with my android phones on the software and apps front and that I personally do not benefit much from the upsides of the "walled garden" of apple. Now the downsides of the walled garden are not as extreme as they used to be for Apple has open up both on apps as well as improve their core OS that usually everything that most people can do on apple iOS can be done on Android and vice versa.
That said for other users who do not have my preference for all of that freedom and the ability to do things with software earlier than Apple. The people who just download apps and use the internet browser the iPhone arguably gives a far better experience than android. But the things that android does well on a software front I personally like better and think that makes the phone more valuable but it only does so to some people but not others.
In other words what is the best phone depends on the person and what do they see as the most important things.
(Now that I said that I will make some form of arcane reference to the manga Attack on Titan about how living in walls is not necessarily always a good thing, and give me my freedom)