Apple bought a chip design company with some of the greatest minds in chip design, with experience in DEC, PowerPC, StrongARM, Itanium, and PowerPC design, and then they poured billions (yes billions) of dollars into designing a very limited set of chips with specifications to do exactly what they needed for their iPhones and iPads and related devices, while buying up other hardware and software engineering companies along the way. Furthermore, they specifically designed chips for low power and not the desktop space. What I mean about designing for their own plans for example is that they went 64-bit before everyone else, and they design their own OS, which meant that they could leave 32-bit behind a lot sooner than everyone else. Apple can plan to throw out legacy features, and then they go ahead and do it, in their chips, in their logic boards, in their OS, and in their apps.
In addition, since those are their own chips, they are not paying profit to companies like Intel for their chip design. Yes they are fabless, but they also are able to leverage their enormous volumes to get great pricing on chip manufacturing, from the best companies. Luckily, both Samsung and TSMC were competitive against each other so Apple was able to play them off each other for the best deal and the best tech. And it turns out now in 2019 TSMC probably has the best tech, even ahead of Intel, so Apple's primary fab is TSMC.