Apple could've just banned those types of MTX, but 86% of the iOS App Store is dominated by that, so ofc. they're not going to say no to "free money".
Apple didn't need to ban them. They could have required all MTX applications to prominently display the odds of any lootbox purchases next to the buy button. They could have not editorially promoted those titles on the front page of the app store. They could have not had the store for years reward MTX games over actual free software by combining them into one chart. They could have made any MTX games rate 18+ automatically. They could have given developers other ways to monetise like upgrade pricing, or subscriptions years before they did.
All of these things could have happened years before iOS revenue was dominated by in-app microtransactions, but they didn't. Because Apple deliberately chose MTX as the primary business model for the app store.