That's why having a full suite of tests is important so that we can fearlessly refactor, so that we can replace a part whose needs we have outgrown without breaking other parts of the system, allowing a "rewrite" to happen organically.
Far too often, code grows stale because nobody wants to work on it anymore. Every change is stressful because it could break something else, which means more time wading through unfamiliar and unpleasant code. So, the maintenance programmer patches it with silly putty and duct tape as to not bother any other portion of the system.
A few years of this and it becomes brittle.
If we have a decent suite of tests, however, we can have an application that doesn't need to be rewritten because the maintenance programmer can attack a problem with the confidence that they haven't broken anything else, and so can make the right solution rather than the least invasive solution.