In 1970 almost every country (currently ~190 signed + Vatican, Palestine, Taiwan[1]) signed the NPT, or non-proliferation treaty. We agreed that if you didn't already have the bomb, you wouldn't get it. All but 5 countries have signed this, including North Korea, who built the bomb and then left the treaty.

The treaty outlines 5 countries that detonated a bomb before the treaty was signed. They are allowed to have bombs. These are:

Other countries (4) that have bombs but did not sign:

South Sudan is not believed to have the bomb, but also has not signed it.

The treaty is renewed every 5 years.

The NPT non-nuclear-weapon states agree never to acquire nuclear weapons and the NPT nuclear-weapon states in exchange agree to share the benefits of peaceful nuclear technology and to pursue nuclear disarmament aimed at the ultimate elimination of their nuclear arsenals

The treaty has three arms:

[1] None of these are officially recognized by the UN.

See Also

Nuclear Energy