Aren't they doing most of the work anyways to have a functioning OS with standard apps?
Great question.
First. I wouldn't guess it was "most" of the work. I would not be shocked if it was less than half the work on an internal API vs a public api that did the same thing. There is a truly stunning amount of work put into Apple's public apis. This isn't just the coding, but the documenting, the training materials and video sessions (produced and presented by the engineers) as well. But more than that even. The stability is rare in software dev, how long an API is maintained before being deprecated. Plus the support Apple provides when it is deprecated (they do a TON of extra work to make sure old apps don't just break one year). An internal API can benefit from many of these, but just don't require the sheer tonnage of effort required.
Second. Even if most of the work for many APIs were needed anyway. Overall it will be much less than half the work. There is CONSTANT development of brand new features, and convenience APIs for developers. Patterns and tools that make it easier to develop faster. To compete with the patterns in other frameworks (which aren't used for app development, but do have modern whiz-bang software dev features). TONS of this work (announced every year at WWDC) is by no means required for Apple to produce its OS and Apps (most of Apple's apps don't get updated for YEARS with these new features).
Third. Who gets to decide how apple can make revenue for its work? Literally every person in here complaining that it's not fair is not appreciating that it wouldn't exist if Apple didn't get revenue to justify the MASSIVE developer expense. Without the same amount of revenue, Apple would cut development, apps wouldn't get as better each year
Truly the pace of new stuff coming out each year is amazing. Before I was a developer, WWDC keynote was my favourite. Now I can't wait to get past the keynote to hear the State of the Union (basically the developer API/features keynote always right after the actual keynote) to hear what new toys Apple is giving us.
Why can they offer access to those APIs on macOS, but not on iOS?
Well they do charge for it on the Mac, just only for App Store apps on the Mac. And not for any app Mac/iOS that doesn't charge the user money.
This is frankly wonderful that so many of us get to use this work for free!
But are you really asking why Apple can't give ALL this work away free if it gives some of it away free?
That's like asking why a lawyer can't do all their work pro-bono. They couldn't do ANY pro-bono work if they weren't paid for the rest of it! Sure there's a host of reasons to do pro-bono work, some of them directly benefiting the lawyer in the long-run. But that doesn't change the fact that they need to get paid or none of it can happen!
Exact same thing with Apple choosing a model of selling its product which works best for them.
Apple needs to justify every dollar spent on expense by making a profit on that dollar. Or they have to cut that expense. This is just how public companies operate.
They choose a shared-effort, shared-success payment model. But ANY model they choose will involve them making the same amount of money for the same amount of work.
(This new model they're offering, lets people avoid the 30% cut model, but they STILL have to pay a ton if tons of users are using Apple's code beyond what's strictly necessary to get an app in the the App Store and open to a completely custom experience.)
This model in turn has created a STUPENDOUSLY profitable app ecosystem.
You absolutely cannot overstate what an impact the Apple App Store has had on consumer software. People just didn't pay for software before. They STILL don't really on any other platform (except some super-closed down gaming distribution systems, but those are different in a lot of ways, especially the profitability for the average joe). That ecosystem is unique and revolutionized an entire industry of software development. Making it profitable for app developers like me to spend years working on apps.
At the end of the day, Apple deserves to get paid for the part of each app that they wrote. If developers only want to use the bare minimum to get their app onto the app store and open on a phone, they don't have to pay Apple any cut at all (just the $99 developer fee to release as many apps as they want).