When you do a search on a search engine, you are NOT searching the information on the Internet in real time. You are searching a previously compiled index of information and documents on websites.
The search engine's index is not exhaustive. There is plenty of information out there on the web that the search engine has not indexed for one reason or another. This is sometimes referred to as the "deep web" or the "invisible web."
Google search results and advertisements that appear on the results page are customized for YOU. Google stores information such as your previous searches, your geographical location based on your computer's IP address, etc. It also sells this information to its advertisers.
The order in which Google search results are displayed is based on several hundred factors, including how many times a page has been linked to from other sites ("PageRank"), where on the page your search terms were found, and how often your search terms were found on the page.
How Search Works
This brief video made by Google gives an easy-to-understand explanation of how Google works.
Cutts, Matt. "How Search Works." YouTube, 4 Mar. 2010. //www.youtube.com/watch?v=BNHR6IQJGZs.