I don't know how this can be illegal, although I agree that the practice is pretty harmful in some ways.
In the AI age for example, almost all platforms are giving it away for free now and costs huge amount of money for them.
They are able to give it for free because their investors expect down the road to make much more money like they did in the Web age and then Apps age. Thanks to the investors of the time we had great run on the web and later in the apps.
In one hand it means that sometime in the future if they corner the market and establish a monopoly the service will suffer, will be used for doing bad things or become very expensive, just what the web and apps has become.
In the other hand this accelerates the technological advancements and deployment far beyond what would be possible in another business model.