Well, this turned into a strange ahistorical crap-fight really fast.
By the time the invasion of Japan was going to happen, most American soldiers and seamen were tired, their moral was getting lower and lower the more and more years they were away from home, and they probably weren't going to be able to put up with an invasion of another whole country at the time. Not to mention if this invasion were to go through, it would costs thousands, if not, millions of American and Japanese civilian lives. Especially considering that looking back on the fact with the information we have now, the Japanese accurately predicted the American landing sites. It would have been an absolute slaughter, and a slug-fest until the end. That combined with the Japanese unwillingness to surrender, recently, they had just crushed a coup over that exact same issue, and the ministers were all pretty divided on the issue, but it does not seem like surrender was going to happens. And mind you, this is all looking in hindsight, going by the American perspective at the time, with the knowledge and intelligence they had, it seemed as though the Japanese were willing to fight until the very last man.
So, conveniently around this time, the atomic bomb had successfully completed it's first tests and was ready for use. It was seen as a way out of the situation they were in, as it, if used, would shock Japan into surrender without mass death as predicted by an actual invasion. They chose targets in Japan of industrial significance, rather than civilian (if they wanted to go with civilian deaths, why not just go for Tokyo?). And after staying up an entire night thinking, Truman ordered the bombing of Hiroshima and Nagasaki. And, well, it worked. The Japanese government folded and signed an unconditional surrender, and while thousands of civilian lives were lost, potentially millions were saved.
Also, remember when talking about this situation, hindsight is 20/20. Now that its, well, 70 years later, and we have most of the stories from both sides, of course we can come up with more pleasant alternatives to bombing Japan, because we know what's happening on either side, what they were thinking, their strength, etc. So instead, it's better to look at it from the point of view at the time, with what intelligence they had, and so forth. And looking at that, using an atomic bomb seemed like the only option they probably had, beside more prolonged and bloody campaigns.