The quality of the HTML used for a website is no ranking factor on Google. There are only two exceptions to this: firstly when using structured markup and secondly in the case of extraordinarily heavy bugs.
For a long time there was the rumor that invalid HTML could influence the rankings on Google and other search engines in a negative way. Checking and fixing HTML can be a very costly and complex endeavour.
This effort can be avoided in most cases: Generally Google doesn't care about the quality of HTML. In yesterday's English Webmaster Hangout, John Mueller from Google gave one feasible reason for this: The simple explanation is that most websites contain faulty HTML - and Google has to rank them anyway.
However, there are two restrictions that you have to keep in mind: If you are using structured markup, invalid HTML can impede or even prevent Google from reading and interpreting this data which in turn can have negative effects on your rankings.
Secondly, in very rare cases there are so heavy bugs that crawling and interpreting of a whole page can be impossible. Naturally this won't help you to reach rankings as well. The good news is that those errors can easily be detected when viewing a page in the browser. Additionally, according to Mueller, these kinds of bugs are very uncommon.
You can find the correspondent sequence in the following video:
Titelbild © makc76 - Fotolia.com