How does google index dynamic websites?
"Crawler" is a generic term for any program (such as a robot or spider) used to automatically discover and scan websites by following links from one webpage to another. Google's main crawler is called Googlebot. Check out this list of Google Crawlers.
Today, most crawlers cannot index the entire dynamic page, but they will index most of the content on all the pages, and that is exactly the end result we are seeking.
After a page is crawled, the next step is to index its content. The indexed page is stored in a giant database, from where it can later be retrieved.
Essentially, the process of indexing is identifying the words and expressions that best describe the page and assigning particular keywords to the page. For a human it will not be possible to process such amounts of information but generally search engines deal just fine with this task.
Sometimes they might not get the meaning of a page right but if you help them by optimizing it, it will be easier for them to classify your pages correctly and for you to get higher rankings.
When a search request comes, the search engine processes it – i.e. it compares the search string in the search request with the indexed pages in the database. Since it is likely that more than one page (practically it is millions of pages) contains the search string, the search engine starts calculating the relevancy of each of the pages in its index with the search string.
For a list of ranking factors you can see Search Engine Ranking Factors and the googlewebmastercentral blog. A good article regarding the indexing issue is "How to optimize a dynamic web site" that will clear you doubts regarding the indexing of dynamic websites.
What does Google index and keep on its servers?
From the Wikipedia article on Search Engine Index:
Search engine indexing collects, parses, and stores data to facilitate fast and accurate information retrieval. Index design incorporates interdisciplinary concepts from linguistics, cognitive psychology, mathematics, informatics, physics, and computer science. An alternate name for the process in the context of search engines designed to find web pages on the Internet is Web indexing.