The Cupertino-based company spent the last several decades carefully cultivating communities of developers writing the software that makes the world hum. Resources were poured to research and development because it has become obvious that the potential is there.
Apple, in particular, is in a unique situation, as an immensely profitable company that also controls relatively little of the market.
Microsoft Windows still controls the vast majority of the PC market. And Google's Android is the dominant power in the smartphone world, and it's only growing, especially in the developing world.
Android and its continued growth is enough of a threat as it is — developers will always be drawn toward building software for the largest audience possible. With the future of computing a continually shifting target, Apple has to make sure that no matter what, people keep building apps for iPhone.
The solution Apple hit upon is typically elegant: Swift, the Apple-created programming language for writing iPhone apps that developers of all shapes and sizes have quickly come to love.
Swift has won accolades and support from the world of app developers by virtue of simply being better, faster, and easier to learn than other options.
Apple has been pitching Swift as the language of choice for people, especially kids, learning to code. And by releasing the language freely as open source, Apple has ensured that Swift has gone beyond the iPhone to platforms including Android and Linux.
The trick here, though, is that Swift was designed to run on an iPhone. So any code that's written in Swift, for any operating system, at any point in time, would be way easier to bring to the iPhone than it would otherwise.
It turns the iPhone into kind of a default landing zone for Swift apps, no matter which way the winds blow in the larger tech space. And if Apple ever releases a new platform — for instance, a hypothetical virtual-reality headset or a car — it would support Swift in the same way.