To end the war because Japan wouldn't surrender. The bombs saved millions of lives that would have been lost in a ground invasion. Read up on your history
Well to be fair that is what we are taught but it was not that cut and dry.
Japan had practically no ability to wage military war anymore, the B29s bombers were all but untouchable. Even without invasion they would have likely surrendered in the near future as the military dictatorship was hanging by a thread. The Russians entering the pacific war was also a major factor for Japan, no chance in China and the Russians had a grudge--plus the troops in China were all but lost. One MAJOR sticking point was the allies terms for surrender, which were absolute including the emperor (including possible war crime charges)--Terms set out in the Potsdam conference if memory serves me right. Military dictatorship or not that was a (maybe the) show stopper. In the end the terms of surrender were modified to not touch the emperor, because even after the bombs it was a show stopper.... So invasion may not have been required either way and more favourable terms of surrender would have also helped (as they did). The simplified grade school History class saved lives vs invasion argument holds little water in the classic sense since invasion was likely not at all required.
As for saving lives, the strategic fire bombing of cities (including Tokyo) could be argued was more devastating than the two bombs, just took a lot more planes per mission... This would have been require to continue until surrender. So if this was to continue there could have been more lives lost in Japan from this type of bombing.
Also, the US needed to show the soviets that they had the bomb and were willing to use it as a preventative measure. This is the best argument for the saved lives because that bit of sabre rattling likely did prevent a third war in quick order (instead there was just water testing in Berlin, Korea, Cuba and Vietnam--proxy wars). Also why it was important to drop it on real cities (and I am not saying this was right or wrong), also a factor in why they did the two so close together, to get a chance to display both technologies before they surrendered.
Finally, don't poke the bear and not expect the bear to kick your ***. So a bit of payback may have also factored in. It was absolute war and both side knew that, as opposed to cowards cutting off the heads of children.
Back on topic, the soldiers involved in the beach invasions (not just June 6) were some of the bravest men ever.