There are certain industry standards the code of web pages should comply with. You can read more about them at W3C Markup Validation Service.
A failure to comply with these requirements can have 2 main consequences in terms of SEO:
It's not that the search engines are hostile to imperfections. The reasons are quite pragmatic. Pages with validations issues take more of the robots' time and resources so visits to them are more expensive. What's more, they tend to load slower. Some elements may work or be displayed incorrectly on them. This hinders users' experience with the website - and user behavior actually is one of the factors search engines take into account. A search engine risks its own reputation referring people to web resources they may not be totally satisfied with.
You can find the W3C validation errors among Technical Factors under Content Analysis > Page Audit.