The 'classic' justification for dropping the nukes on Hiroshima and Nagasaki is that it forced Japan to surrender, eliminating the need to invade the Japanese home islands, which the American planners had estimated would cost upwards of half a million US soldier's lives.
It is certainly true that Japan was on the verge of surrender. The reality was that the dropping of the nukes by the US on Japan was as much about the deteriorating relationship with the Stalin and the USSR as making Japan surrender.
The USSR was on the verge of entering the war in the Pacific and the US wanted to prevent a Soviet land-grab there, given the struggles they were having in Europe regarding territory and 'spheres of influence'. The US thought that it could intimidate Stalin and the Soviet Union into concessions of territory via possession (and later use) of the Fat Man and Little Boy nuclear bombs. President Truman tried the former at the Potsdam conference in July 1945 but Stalin was unmoved.