SEO is short for Search Engine Optimisation, and there is nothing really mystical about it. You might have heard a lot about SEO and how it works, but basically what it is is a measurable, repeatable process that is used to send signals to search engines that your pages are worth showing in Google's index.
Two major functions search engines have: crawling and building an index, and providing search users with a ranked list of the websites they've determined are the most relevant.
Links on your website allow search engines to crawl via automated robots called either "crawlers" or "spiders". Once the pages was find they are deciphered and stored for when needed for search queries. Then it returns only the results that are relevant and then ranks those results according to popularity and relevance.
How does search engines determine relevance and popularity?
Today, hundreds of factors influence relevance. Search engines assume that if the site, page or document is more popular that the information it contain is more valuable.
Popularity and relevance aren't determined manually but there are a mathematical equations call "algorithms" sort the content, and then rank it in order of quality or popularity.
There are multiple variables to these algorithms which is called "ranking factors". (Search Engine Ranking Factors).
SEO information from Google Webmaster Guidelines:
Ensure that your site has a clear hierarchy and text links.
Every page should be reachable from one at least one static text link.
Create a useful and informative, write page content clearly and accurately describe your content.
Ensure your "title" elements and ALT attributes are descriptive.
Use keywords to create descriptive, human-friendly URLs.
Use 301 redirects to address duplicate content.
All content should be in HMTL text boxes.
All images should have ATL text to provide search engines a text description of the visual content.
Supplement search boxes with navigation and crawlable links.
Your can read more about the beginners guide from moz.com