There are several conversion tools that will turn other file-types into an EPUB, but they won't necessarily give you a valid file, that is, a file that strictly follows the IDPF specification. This can mean trouble when porting your EPUB to different readers. And even if you build EPUB files by hand, it's easy to make small mistakes that might hinder readability.
EpubCheck evaluates your file's container structure and markup, and it also checks for internal reference consistency. It's an open source project which you can run on your own machine. If you're not validating EPUBs in bulk for commercial distribution, Threepress Consulting graciously hosts a version of the tool, so you can just upload your file there for validation.
Although the EpubCheck project wiki includes an explanation of common errors, it can be difficult to identify exactly what's causing an error. FlightCrew is another open source validation tool, and one of its key features is that its error reports are very specific and clear. But FlightCrew doesn't completely replace EpubCheck because there are certain errors it doesn't detect (although it also detects some errors that EpubCheck won't find). See the author's introduction for an explanation of the differences.
So, for now anyway, we're using a two-step validation process. Please let us know if there are other validation tools we should know about.
Joshua Tallent's TOC2011 presentation "ePub Finishing Touches: Fixing Errors, Adding Metadata, and Tweaking Formatting" [no talk, but his slides are linked from that page]
MobileRead ePub Forum -- lots of discussion of error troubleshooting