One of the first projects I worked on, 38 years ago, was a nightmarish piece of Fortran, that looked reasonable, but had truly awful performance due to the use of a BACKSPACE command -- worked effectively on tape drives, but for disks it would go back to the beginning of the file and read forward one fewer records. I rewrote it (in VAX Basic, which at times was indistinguishable from VAX Pascal, but that's another show), and it was dozens of times faster, just by avoiding the BACKSPACE.
And years later, I was asked to help the Word Processing support group with some WordPerfect macros, was horrified at the half-recorded/half-authored mess, and said, "give me that, and don't touch it ever again!"... which eventually led to my being an expert in several generations of Microsoft Word VBA.
But I know there's stuff I wrote that I'd never want anyone to fix, only rebuild (some '90s cookie-driven shopping cart Perl code comes to mind).
It's not just "tech debt", it's learning, it's changing of standard ways of doing things, it's just getting better.
That works for utilities, small projects, but is obviously a nightmare for million-line projects.