Even the basic Developer Program License Agreement includes this language:
"Apple reserves the right to change, suspend, deprecate, limit, or disable access to the Apple Services, or any part thereof, at any time without notice (including revoking entitlements or changing any APIs in the Apple Software that enable access to the Services). In no event will Apple be liable for the removal of or disabling of access to any of the foregoing."
The revenue sharing agreement further reinforces that you can't hold Apple liable for anything.
It's Apple's store and Apple's customers. They display your software in the marketplace and provide cryptographic signing so that end users can install it, but they can stop doing that at any time with no justification needed.
A good example is a paid parking lot where it might say something along the lines of "by parking in this lot, you accept that 'parking company' is not liable for any theft, loss or damage of property." however if say a light fitting fell from the ceiling and damaged your car and you were able to prove negligence by the parking company then you may hold them liable for the damage.
Various companies try all kinds of unenforceable contract terms on the basis that the average Joe believes that he has to stick to whatever he agreed to. There was an amusing post on a legal blog where they went around NYC pointing out the hundreds of unenforceable contract terms that we are exposed to everyday.
[0]: https://motherboard.vice.com/en_us/article/a3yadk/apple-sued...
[1]: https://consumerist.com/2012/04/17/seattle-man-victorious-ov...
What’s illegal or unenforceable about this agreement between two corporations?
If Apple was just a random company only running an app store, it'd be different.
But Apple has a monopoly on app stores for iOS and macOS by preinstalling them, similar to Microsoft preinstalling Internet Explorer.
As a result of being the only possible marketplace for these platforms, Apple can't just act at its own discretion.
And the fact is that Apple has acted on its own discretion possibly thousands of times when it came to the App Store. In fact they've been doing it since day 1. They have banned pornography, gambling, cryptocurrencies etc and they will continue to ban more in the future.
It's 100% legal and their right.