First intention, then enlightenment. - Buddhist maxim
With software, quality is paramount. When quality begins to suffer, everything else follows suit. We see higher defect rates, longer delays to implement new features, and generally speaking, a more fragile code base. It also leads to a broken window effect, where modifications and updates will tend to be poor in quality as well.
But what does it mean to say that a piece of software has high quality? I think it means the code should be easy to maintain. And what does it mean to be maintainable? Maintainable code has the property that its intent is clear. Meaning, it's easy to understand what the code is doing, what its goal is, and why it's there. Quality software has additional characteristics as well, but I believe that most of these fall out of its maintainability. One litmus test is to read a piece of code and think about how you would add some additional features to it. If it's clear, then that means the code itself is clear.
A different way of phrasing this is to say that high quality code doesn't violate the principle of least surprise. Code should behave like it looks. When it's surprising, that's a sign that it's not as clear as it should be. A corollary is that two pieces of code that look the same should behave similarly. If they look different, they should behave differently.
So, how do we go about writing code that's high in quality? In my opinion, the best way to improve software quality is simply to care about it. Great code is usually difficult to get right, and it often takes a few failed attempts before a cleaner design can emerge. But these epiphanies will only appear after deliberate thought. And these thoughts will only come to us if we care about improvement in the first place.
Certainly, great code emerges from great effort. There are differing opinions on how to get there, but asking the right questions is the crucial part. It's the intention to improve that leads to enlightenment.