1. The Japanese died rather fighting than surrender (kamikaze)
. To prevent more deaths on both American and Japanese side, the atomic bomb was used (twice).
2. Germany had already surrendered. In order to prevent the Soviet Union from declaring war on Japan as well, thus spreading communism in Asia, the Americans used the atomic bomb.