The military leaders in Japan actually didn't want to attack us; they realized that it was a bad idea. But their superiors overruled them, and their warrior code didn't allow them to disobey their leaders for any reason. (these are the same leaders who invaded Indochina and China, committing all kinds of atrocities there)

We sent them a warning ahead of time what we were going to do, but they still refused to surrender. After we dropped the first one, they still refused. The Emperor, when he found out about Hiroshima, actually wanted to surrender (he had supported the war based on false facts that the war council was feeding him) but the same leaders as mentioned above refused, and even tried to overthrow him so they could continue the war. Fortunately, the coup was put down and the Japanese surrendered a little after the second bomb was dropped. If the coup had succeeded, they STILL would have fought, and even more would have died. And we didn't have anymore bombs (we only made three, and one was detonated for testing) so we would have had to invade.
Had we invaded, thousands or maybe millions more would have died. Civilians as well, because they would have taken arms to defend their homeland. And thousands of our troops would have died as well.