Ah, this discussion. I never grow tired of discussing Loghain. Such an interesting antagonist/rival character. At a glance he seems so undeniably evil, and certainly he does some things no truly moral person would do. And yet there is definite intelligence to everything he does.
-He sets up a stronghold at Ostagar and there defeats the blight army multiple times.
-He predicts the Orlesians are using Cailan and are attempting another takeover...which they are (though in ways not even he quite expected, by their empress seducing him and offering a marriage proposal). Seeing this go down, he preemptively takes out Cailan's strongest supporter by incapacitating Eamon. This is key. Even without Loghain present, there is no way the rest of Ferelden would sit idly while Orlais returned to the country. Eamon was too young to remember and didn't participate in the war, but the Couslands did, as did Howe and most the other lords. Eamon would be the only one who could really muster up support to allow another Orlesian invasion, which would have caused an even bloodier civil war than we saw.
-He realizes Ostagar is likely doomed and concocts a plan to either smash the darkspawn horde or be able to retreat with most his men, sacrificing only outsiders not part of his army. Note two things with this plan. First, Loghain never comes to realize the importance of the Wardens in a blight until the end and, due to how enigmatic they are as well as their centuries old claim that the last blight would be the last, takes a long time to be convinced it is a blight at all. Second, he did not want Cailan a part of the standing army and repeatedly tries to convince him not to go. Third, judging by the number of darkspawn we see (on the bridge, we can clearly see their torches winding up into the mountains in the distance) he actually makes the correct choice abandoning the field. The battle was unwinnable and his force would have been slaughtered should it have attacked.
-With Cailan and the Wardens dead, he actually does a pretty politically savvy thing and blames the Wardens for Cailan's death and placing a bounty on the remainder's head. Questionable, yes, but it helps keep at bay any lingering support for Orlesian reinforcements and, on paper, doesn't cost him anything as the Wardens should all be dead with any possible survivors few and far between, making blaming them, while unjust, cheap, easy, and rewarding. He just had no way of accounting for Flemeth's intervention.
-This done, he does exactly what the Warden sets out to and gathers allies. The problem? The mages reject his offer because Wynne doesn't like that he quit the field (despite it being the sound choice) and the dwarves have locked themselves tight in the midst of their own power struggle.
-While this is going on we get to...the civil war. A war which he didn't start and one which ends up as rather senseless. Loghain is trying to gather allies to fight the darkspawn so Teagan and other lords begin a civil war to...oust him? Why? In favor of what? He's a regent in a time of war, not an actual king (his daughter still holds official title). So what is it they want to do? Alistair isn't in the picture yet and Eamon is sick and dying for all they know so they're starting this civil war with no leader to put in place. Looking at this, Loghain is actually entirely blameless.
-Then comes the assassins. Once the Wardens come back into the picture Loghain quickly realizes the threat. He made a mistake blaming them when they've managed to escape into the country proper, but he can't just call it off and make amends. It's too late for that. Neither can he sit and let them be as they're going to attach to the opposing faction in the civil war and become a symbol to rally around, making it more difficult for him to gather allies for the fight. So he accepts hiring the Crows to do away with them quickly...which they fail at.
-And then we come to what we all recognize as his single most evil act...which also happens to be one of his most intelligent decisions. Loghain is desperate by this point. He's at a loss for allies, resources are dwindling, and his most effective subordinate is skimming the few remaining resources off the top. Meanwhile the blight is bearing down. So what does he do? He allows Tevinter to come in and enslave the elves, eliminating three birds with one stone. First, it allows him the gold needed to help fund the war effort. Second, it depopulates an overcrowded and otherwise useless portion of town so he can more easily maneuver within the city should the need arise. Third, it opens up talks with Tevinter, the most notable collection of mages in the world, and ones who would have no interest in taking over Ferelden considering how isolated it is from them and yet have every reason to join the fray considering their history against the darkspawn.
In the end, it's comical the string of bad luck Loghain endures throughout the course of the story. He predicts everything which can be predicted and reacts intelligently to what happens considering the state of things, but there's so much working against him. Cailan and the Orlesians basically make him into our antagonist rather than our greatest ally and Duncan being so secretive pretty much eliminated any chance of Loghain reacting properly until it was too late.