And everyone benefits. You, the employer, your colleagues, the fresh grads with starry eyes
First, management has to be willing to assign you to cleanup tasks, rather than have you work on new features.
Second, cleaning up spaghetti code safely and turning it into something maintainable is often not easy -- it wasn't written to be maintained! No tests, missing documentation, ill-considered interfaces...
It isn't enough to keep your head off the chopping block: management has to be fully on board.
I found an impending any-day-now production down scenario last week and got it fixed while learning tremendously and fixing some incidentally related things. It feels amazing.
No tests, no docs, no comments, total spaghetti, global variables everywhere, no logs, and I am loving it. What a job.
Upper upper management is starting to keep tabs on the "productive" output of my team though. We'll see.