In order for Google to understand what the best content is and why it deserves to be #1, it has to rely on machine learning, but because understanding language and intent are particularly difficult, it will sometimes make mistakes and return content written by automated software and not even a person.
It would be impossible to manually review each piece of content on the web and judge its merits, so certain metrics are used to break down a page in to its constituent parts and analyse them.
These include the keywords or "words and phrases" included in the copy of the page, the amount of time spent by users on the page and the amount and quality of linking websites to the page.
It is important to take note of the fact that Google ranks webpages, not actual websites themselves for the keywords.
Making sure, you understand this is vital because Google search results return the webpages for queries and not just the website homepages, when people search for keyword phrases.
This can be considered as a positive for a mediocre website owner, as it means that you will not be automatically outranked by a good website for the keyword that you are targeting.
Even if a website has, a good backlink profile and good content it can still be outranked for a specific keyword by a website that largely has inferior content and less backlinks.