The Lady Anna and the Lady Secca from the Spellsong Cycle. Lady Anna took over after the former weak but well meaning Lord of Defalk was killed in an invasion, and after killing the foreign king who tried to move in during the power vacuum. She was technically only a Regent for the heir, but being an extremly powerful sorceress ( and strong willed, clever, etc ) was actually stronger than any former ruler of Defalk. She defended it against repeated invasions, reformed the government ( with plenty of casualties ), placed a number of females in power in the formerly patriarchal Defalk ( again, with plenty of casualties ), ended an artificial drought, set up a roadbuilding program via sorcery, and in general shaped Defalk in her image. Lady Secca twenty years later was forced to execute the heir, who proved both incompetent and willing to sell out his own country to it’s mortal enemies in order to stay as a puppet ruler; she took his place as ruler because she was the only one the Lords would accept. She did so after finally defeating those same enemies.
Lord Kalvan from Lord Kalvan of Otherwhen : Accidentally transported from our world to a more primitive one, Calvin Morrison sets up an Empire to oppose the corrupt and ruthless Temple of Styphon, which rules via it being the sole source of ‘fireseed’, aka gunpowder, which it passes off as a miracle of Styphon. He just happens to be a a veteran who knows how to make gunpowder. Pretty consistently works for the general benefit of his people.
Emperor Herdan of the Fourth Imperium and Colin McIntyre, founder of the Fifth Imperium. Herdan took power after a nasty six sided civil war, during which the former authorities lost legitimacy in the eyes of the public. He couldn’t give up power even if inclined, since as the man who ended the wars he was the only one left that most of the population regarded as an acceptable authority. In order to ensure there was never such a war again, he set himself and his successors up as having sole control of the military, enforced by computers integrated in all major military equipment. In order to keep this from turning into a tyranny, he set up a parliament, the legal process to remove an Emperor via popular vote, and routed his computer-enforced military authority through Fleet Command’s central computer, also known as Mother.
Mother is non-sentient ( so no personal ambition ), can’t be reprogrammed in certain areas touching the Imperial succession ( so can’t be subverted ), and is empowered and capable of judging the Emperor’s legal status and competency to be Emperor. Someone who’s insane or stupid is disqualified; someone who’s voted out will suddenly find all his military machinery obeying his successor and not him.
Colin McIntyre basically ended up in a similar position as one of the very few people acceptable to everyone as humanity’s central authority ( and humanity needed one, what with genocidal aliens coming ). He also needed the military equipment of the dead Fourth Imperium, which meant working through Mother and having himself declared Emperor.
The Protector of Grayson from the Honor Harrington series. After taking back the power that his ancestors lost, he’s proceeded to reform his planet socially, while at the same time building it into a significant military power and economic prosperity.