Refactoring is the process of improving the internal quality of the code (from "a big mess" to "squeaky-clean and modular code"), while not changing its external behaviour. This is done for mostly functional and bug-free, but sub-optimally-written, code so it can be better managed.
"Joel on Software" features two excellent article about the motivation for refactoring: "Things You Should Never Do, Part I (why rewriting functional code from scratch is a bad idea)", and "Rub a dub dub" (how and why to do refactoring)..
There are many other resources for that online, along with many refactoring patterns.
There are many types of refactoring: grand refactoring sessions (= what Joel describes), continuous refactoring (refactoring as you go), "just-in-time refactoring" (refactoring enough to achieve a certain task), etc.
But refactoring is important, makes development faster in the long run (and even in the short-run), and can prevent the code from deteriorating into an ugly, non-functional mess that would be hard to salvage.