The basic algorithm is quite straightforward, it's the scale and edge cases that make it hard to compete.
"Ideally", from a pure data perspective, everybody would have all the data and all the processing power to search through it on their own with whatever algorithm they prefer, like a massive P2P network of per-person datacenters.
Back to reality, that's pretty much insanely impossible. So we get a few search engines, with huge entry costs, offering more value the larger they get... which leads to lock-in, trying to game their algorithms, filtering, monetization, and all the other issues.