>Companies pay Google with the money they got from you
You talk as though this has already happened, but that's not the case. Companies pay Google with money they hope to recoup from you via your purchases, but whether or not you choose to buy the thing advertised is completely up to you. Advertising is an investment with uncertain returns, like any other.
>If online advertisement became illegal, Google or somebody else would have gotten off by selling search as a service.
It's possible, but I just don't think there's enough of an appetite to pay small amounts of cash for this. It will be interesting to see what happens with Kagi (though I acknowledge that if it fails, that would not be definitive, since it has to compete with ad-supported services, and massive, entrenched ones at that).