Because the atomic bomb was never the reason why Imperial Japan surrendered; it was because of the Soviets. Japan and the Soviet Union signed a non-aggression pact, which gave assurance to Japan that Soviets would not attack them during the war. The non-aggression pact became irrelevant when Germany attacked Soviet Union, despite the two also signing a non-aggression pact, and both Germany and Japan were allies.
Multiple factors underlie the Japanese decision to surrender as well as the U.S. decision to use the atomic bomb.
Imperial Japan was seeking conditions of surrender in the month or so leading up to the bombing of Hiroshima and Nagasaki. By this point, loss of strategic holdings and the persistence of U.S. strategic bombing efforts pretty much reduced the outcome of the war to a statistically guaranteed failure. Imperial Japan knew that the only chance it had at surviving destruction was to seek terms of surrender.
Worse still, the Russians were making advances on territory the Japanese no longer had the capability to hold, much less garner resources from. Japan was doing everything it could just to stay off complete collapse.
Historians agree on that. The whole fucking world agree on that. Only you Americans disagree. Who's the stupid?
Historians are somewhat divided and it depends upon which sources they consider to be credible. Further, as records of the era have become declassified and various personal journals kept by key individuals of those times have become published in searchable databases, Historians have generally had to revise their view of the decision making process.
Obviously, the general American public was not aware of Imperial Japan's seeking terms of surrender and it wouldn't be for a few decades that various statistical reviews would be published. This was plenty of time for it to become fairly deeply ingrained in the public and in history books that the dropping of the atomic bombs and the surrender of Japan were a direct cause-effect relationship.
What we have been able to see behind the decision making process as things have become declassified is a bit more complex. The U.S. had more problems than Japan. The battle for Germany left the region divided with Russia refusing to turn seized territory back over to the constituent nations. Russia was turning the war into a territorial conquest, and was making advances in the Asian continent to seize territories held by Japan.
There were various interests at play, but they broke down into a general dislike for the Japanese Imperial system of government. Almost no condition of surrender would be accepted in which the Japanese preserved the emperor. Other concerns focused on the territory acquisitions of Russia and believed that the Russians would challenge U.S. capability to protect Japan's territorial claims in the event of a surrender. If the Russians chose to continue their advance, it would mean the war would simply continue with the Russians as the new enemy and the Japanese as a potentially uncooperative defense liability.
The decision was made to drop the bombs largely as a display to Russia and a reminder to Japan. Comparatively, the Atomic Bomb was not all that devastating when compared to a typical bombing campaign. Japan had already lost a few dozen cities and another two was simply water under the bridge - the fact that it was a single plane may have been noteworthy, but it wasn't as if the Japanese were being very successful at intercepting strategic bombers at that point - whether it was one plane or a thousand, there wasn't much they could do against it.
It was, however, a game-changer for Russia. If strategic air defense failed to intercept even one aircraft - large sections of a city could be forfeit, and the more likely scenario of 70% or more of a strategic bombing wing making it to their designated targets made for an absolute nightmare if they were armed with these weapons.
It completely changed the risk and cost factor of a war with the U.S. The U.S. didn't need to field large armies and work nightmare logistics abroad. They could move much smaller teams to air bases and send these aircraft over the horizon armed with bombs that could make even one-way 'suicide' missions worth the loss of both crew and aircraft.
So - arguably, dropping the atomic bombs prevented a war with Russia more so than it prevented loss of live in Japan. The argument could also be made that it squelched ideas of rebellion against the U.S. within Japan - as it did leave quite the cultural impact.
As for whether or not it was 'necessary' or 'good' - that is what we like to call "Monday Morning Quarterbacking." While the reasons underlying the decision were more complex than a simple "we needed to get Japan to surrender" - the statistical implications of a conventional war against the Russians as a continuation of World War II is worse than any single invasion against mainland Japan ever could have been - even for Japan.
It can also be argued that territories like South Korea would be currently dominated by the Kim family from what is currently North Korea - which means no Samsung or LG. South Korea is also one of the only places in the world that manufactures triple-hulled tankers for oil and natural gas. So there is that, as well (not that it couldn't be done elsewhere - but it's where it is, now).
Would it have been "better" if the U.S. had not dropped the atomic bomb on Hiroshima and Nagasaki?
It's an impossible question to answer, frankly, and is very dependent upon just what qualifies as a 'better' outcome and how many additional factors are considered (and over what time frame). Everything looks like it would have been much better if we hadn't dropped the bomb - until you figure that Russia may very well have continued to press into Japanese occupied territories and we ended up nuking Russia, instead (and it being far less decisive - necessitating a more protracted war... though perhaps defeating Russia and dethroning the communist party, alleviating the stresses of the Cold War ... but at what cost).
There's a lot of what-ifs that can be tracked down from now until the end of time. Even if we had a full set of recordings of every meeting and letter that was involved with this decision, the fact of the matter is that some people will agree with the reasoning and others will disagree with the reasoning behind the decision.
From my personal standpoint, I have not seen enough evidence to suggest we were 'wrong' in what we did. It may have been horrible - but given the options, I can't say I've seen the evidence that our reasoning was fundamentally rooted in malevolence or something that would have me rushing back to change history if I could.
To contrast this - my opinion on America's involvement in Yugoslavia is that I'd change that if I could - and have every intention of apprehending the Clintons and throwing them before the Serbs to let the Serbs figure out what they wish to do with the family that decided to falsely portray them as genocidal barbarians to justify destroying a sovereign state.
THAT is a bit of history in which America's foreign policy crossed the moral event horizon and the heads of that whole fiasco need to roll.
Of course, you hardly ever hear about it.