The atomic bombings were the culmination of the war Japan started at Pearl Harbor. Four years of island-hopping, firebombing, and blockade brought the US to Japan's doorstep. The bombs were chosen to avoid a projected million-plus casualties from an invasion (Operation Downfall).
Moral debate persists, but the strategic line from December 7, 1941 to August 1945 is unbroken.