SEO or Search Engine Optimization is the science and art of optimizing a web site, so the site gets a better search engine ranking when a user searches for a specific keyword.
There are two SEO methods to get a web site better ranking:
Onsite optimizing that means applying technics to content of a given web page. It includes many methods like using a good density of keywords in content of the page or using some special HTML tags like <h1> to emphasize the importance of a specific keyword.
Offsite methods like getting links from other web sites, specially from credible sites with good reputation and rich content.
Search engines usually provide recommendations like comprehensive documentations and even services to help webmasters optimize their sites. The recommendations should be followed in order to get a better web site that both search engines and visitors like and prefer.
Some webmasters try to fool search engines by applying illegitimate technics like showing two different versions of a page, one for visitors and the other one for search engine robots (bots) or spamming the search engine by using duplicate content to get a better search ranking. Those technics might work for a short time but eventually lead to getting banned by search engines.
The golden rule is to provide rich content and a great experience for visitors. The content is the king as all webmasters agree on.