Right now, the US, China, Russia, North Korea, India, Pakistan, and Iran are the major contenders for dangerous governments, particularly with that caveat of "if they wanted to" because the US is fairly stable in spite of the current leader but if the worst of the current administration truly gained control with no checks and balances whatsoever, seizing all power in a true dictatorship with malevolent intentions, the US simply has the most firepower. We could take on most of the world together all by ourselves. I'd genuinely bet that if the US wanted to, it could handle the combined might of all of Europe, Africa, South America, and the Middle East if Australia, Mexico, Canada, and all Asian countries stayed neutral. That is a disturbing amount of power for one country to hold, no matter how stable it is.
In terms of a more objective threat to life on Earth, Russia is probably the most dangerous, because it's just so unstable right now. It appears stable with Putin, but one 66 year old man in charge of a kleptocracy with multiple factions at odds with each other and the world is not what I'd want to rest the stability of the country with the most numerous and powerful nuclear arsenal in the world right before it withdraws from an arms reduction treaty and begins a new arms race. If Putin dies suddenly, the world is fucked. Russia will not stay united, it will split along various lines of power and not all the tens of thousands of nukes would be in the hands of sane men. There are some terrifying anti-Western radicals whose paranoia outclasses some of the West's worst culprits in the conspiracist right. They absolutely would launch nukes preemptively if given the chance, and would be easily provoked into doing so. They make Kim Jong Un and Trump's saber rattling recently look tame and unalarming by comparison. And at least some of Russia's nukes will end up in their hands if Putin dies suddenly without clearly grooming a successor.
China is certainly a threat to the current world order of western civilization holding most of world power, but I don't think they're a danger to life on Earth. They're just fairly pragmatic and nationalistic. That makes them very dangerous to be sure, but not as catastrophically so as Russia would be. If Xi Jinping suddenly died without a clear successor, China too would be at risk of breaking apart, but it would be along much safer lines, with Hong Kong and Taiwan and maybe even Tibet standing a chance at true independence, which would be nice. Meanwhile having several Communist China factions as rivals to control what was left would be good for the rest of the world. Some are very anti-Western, but none of them are blow-up-the-world-on-a-whim crazy like some of Russia's oligarchs.
North Korea is a bit of a wild card because of their relationship with the US and China's firm support of them, as well as Russia's occasional dealings with them. That creates nuclear instability, but if China wanted the Kim regime gone, it could be done safely for all countries. Iran is pretty nuts right now and honestly a bit scarier to me than North Korea, because their theocratic government is completely nuts in a way only a religious government could be. It's basically a slightly more stable, slightly more pragmatic, much more legitimized, and not quite as viscerally horrifying Islamic State. What makes it truly scary is that it really could become a nuclear power, and I'd sooner trust Kim Jong Un with nukes than Iran's Supreme Leader.
India and Pakistan are dangerous to the whole world because of their relationship to each other. If I were a betting man, and I knew Putin was going to live long enough to install his successor, and I had to bet who would start the first nuclear war, I'd put good money on the conflict between India and Pakistan being where WWIII starts, at least at this point. Conflict is escalating, there's an entanglement of alliances much like in the previous world wars that could drag more combatants into the conflict, and both are nuclear powers. Also Pakistan is full of terrorists and there's no telling if their nukes are really all that secure. Ours sure aren't in the US, so I doubt Pakistan's are either. One of those terrorists could get ahold of a nuke and launch it at India or even the US (though we might be able to stop it if it were just a few of them). The best we could hope for in a nuclear conflict between the two is that all alliances are severed with both of them to avoid escalation, and that the conflict is contained just just 100 nukes or so, causing a small nuclear winter that the planet could just barely survive if we worked together and only India and Pakistan had sustained much damage to major infrastructure.