Search Engines evolved from directories, a searchable datastore of webpage models organized by categories or keywords. While this sufficed for finding information that matched the text of your search query, the internet community was always aware that text matching alone wasn’t enough to ensure relevance. Something had to done, so Google developed a pagerank algorithm which revolutionized online search.
Fun Fact: Google was originally called ‘backrub’ but that name was later dropped in favor of a play on the spelling of Googol, the number 1 with 100 zeros after it.
While the exact algorithm for determining the pagerank of Page X remains a closely guarded secret, it’s generally accepted that Page X’s pagerank is more or less determined by the summation of ( pagerank / out-links ) of all pages linking to Page X. This means the more pagerank a page already has, the more it will pass along to the pages it links to.
Using only pagerank, Google has no idea what your site is about, it’s just a measure of authority. So when you type a search term into Google, what exactly happens? Why are the results so accurate? Well that’s another closely guarded secret, but my best guess is that Google will match your search query against it’s enourmous datastore of over a trillion pages and find records with matching text, then it sort these results by pagerank and some other factors including results from relevancy algorithms and penalties. That sorted list what’s served up as the results for that search query.