High quality is more expensive upfront but goes relatively cheaper as maintenance and modifications is progressing. The opposite applies to low quality software.
Similar with real world situation, some things are more expensive upfront while cheaper in the long run.
What about the fact that many pieces of software are needed for a particular purpose and will eventually be retired or replaced by a rewrite in whatever tech seems modern at that time?
Or the fact that project based thinking is still pretty popular in certain parts of the world - once you finish writing the piece of software for your clients and they receive the codebase, it's no longer your problem anymore.
The opposite also exists, of course, codebases that have been around for a decade in COBOL or something, are still mission critical, but nobody really knows how they work.
And second system effect is also very much a thing to keep in mind, when thinking about rewrites. Though I also agree with a statement that I once heard: "Don't just write code to be easy to read and change, but also easy to delete and throw away."