Nobody sets out to write bad code. It is easier not to suck if you can control / choose the scope of your project. But more often than not, the scope is dictated by a real-world set of complex needs and circumstances that evolve throughout the whole live of the project.
In the end, good UI, proper testing and responsive customer support play a bigger role in customer satisfaction than the quality of code.