Let me preface this by saying that I believe in giving credit where credit is due, so this will not be an anti-Apple comment despite the fact that I am not an Apple fan. At all.
Apple earned such a strong position on, I believe, two fronts.
The first and foremost prong being a robust philosophy, appealing to users who like to think of themselves as independent thinkers. This was really cemented by their famous Super Bowl commercial rejecting the Orwellian drones: a marketing coup, to be sure, since Apple is and always has been rabidly anti user freedom. People who identify with this take strong pride in their allegiance to Apple. This is brand loyalty. The gadgets Apple makes really take a backseat to the "Why" that people perceive about them. Users display the logo proudly. As Simon Sinek pointed out, Apple's laptops and notebooks are the only major brand where having the lid open displays the logo right-side up to observers.
The second prong is that they have repeatedly entered industries where they did not conventionally even belong, brought novel innovation that both revolutionized those industries and, for a time, allowed the company to dominate them. Take cellphones as the prime example: before the iPhone, there were a handful of shitty flip handsets available, the capabilities and limitations entirely dictated by the phone service carriers. Smartphones did come to exist, but were a niche market almost entirely confined to business people using them as work phones, and a handful of bleeding-edge tech geeks. But when Apple (a computer company) entered the cellphone business, THEY dictated what the phones would do, and the carriers were given the option to cede control or watch the iPhone debut on a different carrier. AT&T accepted, the entire industry was flipped on its head, and now iPhones and Android devices are THE dominant devices.
As a side note, yes: Steve Jobs was famously a lunatic control-freak. But he was a visionary, and together he and Wozniak ensured that his vision stayed consistent by controlling both the hardware and the software, and he wasn't afraid to enter what are nominally considered unrelated markets. With the death of Jobs, the company remains in a strong financial position but may lack the leadership to continue to innovate.
It is now pitch dark. If you proceed, you will likely fall into a pit.