Using valid markup that contains no errors is important because syntax errors can make your page difficult for search engines to index. Look for a W3C validation service and use it on your website whenever changes are made to your website's code. While this is not the most important thing that you need to worry about in your SEO strategy, it is important to minimize these errors so that your website will look better and retain visitors longer. Search engines show appreciation to sites whose visitors stay longer.
There are many online tools that you can use to cleanup your html code, tools that would identify the errors and give suggestions on how to correct them. Simply do a Google search for "Cleanup my html code" and carefully review the pros and cons and start using them.
A clean code also help you to save time when you are revisiting the codes for maintenance or upgrades.
Note: It is pretty hard to pass the W3C compliance test, so do not spend too much time on this, unless you really want to have an outstanding website.