Originally Posted by
Aundas
Nev beat me to the answer but to expound on it, Revan learned of the Sith Empire during the Mandalorian War, knew that they were going to return and became a villain in order to save the galaxy. By becoming Darth Revan and waging war on the Republic he could be selective about the planets he conquered. He left the structural integrity of the Republic intact, only intending to prepare them for a war greater than the one he was waging. That didn't pan out well thanks to Malak betraying him and destroying planets that would've been instrumental to the Republic war effort, and so after he regained his memories he went to the Unknown Regions by himself to defeat the Sith Empire. Obviously he didn't succeed in stopping them, but he probably delayed their invasion.
Most of this is explained in KOTOR2 if you have enough influence with your companions to piece together the story.