Actually today it is widely accepted (except in the US) that Japan was on the brink of surrendering before the bombs were dropped and they did very little to hasten the end of the war or save lives.
Japan didn't want to enter a war with the US. It knew that winning would be extremely difficult, if not impossible. Japan was already committed in its own region. Geographically the US is too large to easily subdue, let alone its vast military strength and huge natural resources. The attack on Pearl Harbour was a desperate move designed to cripple the US navy and if not prevent at least delay a war while the US rebuilt. Japan felt that war with the US was inevitable at that point, but certainly didn't want it and had little interesting in conquering the North America. If they had invaded, Canada would surely have joined the fight.
Once the war started they were hoping that their pacific fleet would win it for them, or at least draw the US to a truce/stand off. Due to some bad luck and the skill of the US Navy that didn't work, and then they were screwed. By the time the atomic bombs were ready Japan was already on the brink of being forced to give up. People were starving, the military lacked many basic resources and couldn't defend Japan against US air attack effectively, nor retaliate. Many people in the government were pushing for a negotiated truce or surrender that allowed Japan to keep its emperor and some dignity. With Russia looking like it might attack from the west it was obvious that the end was near.
The US knew that Germany and Japan had been trying to develop nuclear weapons, but failed to do so. The assumption was that other countries would develop them eventually though, and atomic warfare would be a real possibility. Little was known about atomic weapons and their effects on cities and people, and there wasn't a great deal anyone could do to answer those questions at a time before computer modelling and advanced medical science. Japan was an opportunity to test nuclear weapons and see the results first hand. The Japanese people had already been demonized through years of propaganda, so there would be public support if it was sold as saving American lives. There were two types of bomb available and they tested one of each.
After the surrender US scientists and doctors were sent to the bomb sites to examine them and the people who had been injured. A lot was learned. Some were taken back to the US for treatment, billed as a humanitarian effort but actually more of an opportunity to study the effects and learn how to treat atomic burns with skin grafts and practice facial reconstruction.
Any claim that the bombs saved lives is speculation at best, and not supported by the facts. The horror of what happened is very real. I don't blame modern Americans for it, just like I don't hold modern Germans responsible for the Holocaust or modern Japanese responsible for the atrocities committed during WW2. I find it interesting that people sometimes criticise Japan for not acknowledging what it did enough these days, when the US hasn't even got as far as an acknowledgement for the most part.