They actually can't. Not legally, anyway.
I am not a lawyer, but Nintendo famously lost a lawsuit, when attempting to block third-party software distribution : https://openjurist.org/16/f3d/1032/nintendo-of-america-inc-v... Sega (back when Sega was a major console competitor) also lost a similar lawsuit, when attempting to block third-party software distribution : https://openjurist.org/977/f2d/1510/sega-enterprises-ltd-v-a...
If we still had anti-trust enforcement, this should set precedent against what Apple is doing here today. We already decided this issue in the 80s and 90s, making a specialized locked-down computer (i.e., a "game console") does not entitle you to own the entire software market for that device. And so long as you don't steal copyrighted materials to do so (see Nintendo v Atari), you are allowed to reverse engineer and sell your own software for these devices, without any royalties or licensing owed.
If you want iPhones to be treated like "gaming consoles" instead of computers, then it is already legal to jailbreak an iPhone, distribute your own apps (or entire app store) and sell to iPhone users, without ever paying Apple a single penny.
It's even legal by precedent to modify other people's software when selling your own third-party software (see Game Genie / GameShark lawsuit, it's legal to sell a program that modifies someone elses copywritten software, so long as you don't include or redistribute the original copywritten code).