The precise factors for search engine ranking are closely held secrets of the various search engines, and they are tweaked all the time.
If they were common knowledge, then people could 'play' the engines and make their site come up on top no matter the relevance.
Search engines also use disqualifying or demoting criteria. For example, repeating a key word over and over will get you demoted or banned, as will placing text in white against a white background, or creating multiple copies of the same page at different locations, or autodirecting from one page designed to capture search engine hits to your 'real' page.
People spend a lot of time and money to jockey for position, especially in hot markets like hotels, casinos, porn, bargain shopping and entertainment.
It is an ongoing course of study to keep up on the latest techniques and changes in search engines. You can subscribe to services that will play the ratings game with your site, or you can subscribe to newsletters that will presumably educate you how to evaluate and upgrade your own site's listings.
My current peeve is trying to find some real product reviews among the gazillion shopping "search" sites that are hoping to get some affiliate income by listing every product in the world and then linking to the real seller. Nextag is the grandaddy of this.
You can also buy keyword advertising links that appear at the top or at the side of the search results, but not normally withing the results themselves.