Businesses pay for the sponsored ads; there's a complicated process called "Ad Words" that figures in a number of factors to rank web sites according to their relation to the search terms. Businesses pay according to the hits they receive.
The other search returns are ranked according to a top-secret algorithm that Google developed that uses search bots to crawl the internet looking for the key search words in web sites. Web sites are then cataloged into a database according to the key words used to find them and the number of times they are returned in searches.
If you don't want Google to list your web site in its searches there is tags that can be written into the web page's source code that will prevent it from being cataloged.