The resources below cover a lot of ground with regard to designing code that is easy to test and maintain in the first place, as well as how to refactor existing code to accomplish the same.
Good code design is a critical ingredient of a delivery pipeline with fast feedback loops. Fast feedback loops in turn enable us as developers to deliver stable software in a truly (not just in name) Agile team. When it is quick and easy to research, design, experiment, test, deliver, and repeat; development is exciting and rewarding and customers get the features they want and the fixes they need without delay.
By contrast, bad code design will eventually sabotage all efforts related to speed and stability until the technical debt accrued becomes so great that the entire project slows to a crawl. Releases will be less frequent, and what does get released will not be stable. Eventually, morale inside the team and confidence outside the team become damaged, and that's not a fun place to be.