Agile Manifesto Principle 7: Continuous attention to technical excellence and good design enhances agility.
In waterfall projects, the technical excellence happens at the start through focus on good design and architecture, and happens again at the end of the project by focusing on finishing features and fixing bugs. In the middle, do whatever or in best cases, the technical excellence is reduced in favor of just delivering a working product.
In Agile projects, continuous attention to technical excellence is happening all the time through Test Driven Development and continuous refactoring. Also, there is a continuous attention to quality through validating stories with the customer and bug fixing.
If one of the core concepts of Agility is responding actively to change, then having technical excellence will help us responding to change. No doubt, changing a system that is bug free and have a good design is much easier that changing a system that has poor design and has lot of bugs.