Even in a hypothetical situation where ads would no longer be the driving force of algorithms, something else will. As soon as something gets large enough, it will be gamed. If not for commercial reasons, it might be cultural/political influence.
I will end by reminding ourselves that us techies should spend some more time with ordinary folks. I agree with everybody here that Google Search has been getting worse and worse for years now, especially for our niche searches.
It's a mistake though to think that this is widely experienced as such. My mum looks up an unknown ingredient in a recipe and within a second sees a picture of it. That means it works. All kinds of personal data might be shared in the process but since you can't really see that, it didn't happen. From her point of view, Google Search works extremely well and is close to magic.
The point being, Google doesn't give a shit that you don't get the best answer for your query on JavaScript closures. Nobody searches for that, and those that do, block ads.