The United States used the atomic bombs in order to end World War II and to prevent further bloodshed. The war had already been going on for six years, and an estimated 50 million people had already been killed. The United States believed that dropping the bombs would save more lives in the long run, by bringing the war to a swift end.
However, the use of atomic bombs also resulted in the deaths of hundreds of thousands of civilians, and some people believe that it was a war crime. The bombs were dropped on cities that were not military targets, and many innocent people were killed.
Ultimately, the decision of whether or not it was legal to drop the atomic bombs on Hiroshima and Nagasaki is a matter of opinion. There are valid arguments to be made on both sides of the issue.
It is important to note that the use of atomic weapons is now prohibited under international law. The Treaty on the Non-Proliferation of Nuclear Weapons (NPT), which came into effect in 1970, prohibits the development, production, and stockpiling of nuclear weapons by non-nuclear-weapon states. The treaty also prohibits nuclear-weapon states from transferring nuclear weapons or nuclear technology to non-nuclear-weapon states.