Most developers might want to rewrite legacy apps from scratch, but when the business needs to move forward that is not a viable option. Any codebase can be refactored and remodelled incrementally to meet your needs and become up to date once again.
Like in every branch of engineering there are proven design patterns that can be applied to improve the reliability and robusteness of the software.
More often than not codebases become hard to work with because they haven't kept up with the evolution of the business they serve. Software can always be remodeled to meet the user's needs.
It is easier to grow a product when changes can be made with reliability. Automated testing makes sure that every time a line of code is edited, no regressions are introduced in the product.