The book, "The Making of the Atomic Bomb" is a must read for anyone really interested in a complete history of the bombs, the people involved politically and scientifically, and the the usage of said bombs on Japan and later.
A couple of interesting things about the bombings in Japan (from the book):
1. As early as 1943, those highest in the US had planned on dropping the bombs on Japan. Before they were developed, and as the war still raged on in Europe, the plan was to drop the bombs on Japan only. The book doesn't necessarily explain why, which is one reason why I like it, but it makes you wonder why it was ok to experiment on the Japanese but not the Nazis...
Although there was definitely racist sentiment towards the Japanese during the war, I don't think it played a huge part in this particular decision. If anything, I would suppose that the main reasoning for not using it on Germany would be due to the assumption that Germany would surrender without needing to resort to the bomb. In fact, I would say that they were terrified that using the bomb would provoke Hitler to take even more drastic measures (Resorting to Chemical Warfare, speeding up his genocide) in the face of total annihilation.
It may have also had to do with Soviet success up to that point, since it can be assumed that by this time, many were aware that an Allied-Soviet victory was inevitable in Europe. The Atomic Bomb was the US's "Ace in the hole", and wouldn't want to reveal it until it was absolutely necessary. They wouldn't want to use their secret weapon in a situation where the Soviets were going to win anyway. And even if they did use it, they would have gained nothing in the long-term, aside from gaining the hatred of the entire surviving German population. If anything, it would have allowed for an even greater Soviet influence in Europe following the war, as the German Army would have shown fiercer resistance against the Americans in the west, slowing their advance, as they were no longer the kind alternative to whom they had no objection to surrendering to, to the menacing Soviets, but rather a genocidal force that destroyed entire cities at will.
2. After the bombs were developed, there was a lot of discussion on how to utilize them to end the war in Japan. Along with the plan of dropping the bombs onto a populated city, there was some discussion about making a highly visible showing of the power of the nuclear weapon over some unpopulated island so that the Japanese (and presumably the Russians), could see what we were capable of without killing anyone. The idea was that if the Japanese leaders saw what we could do to them that they would surrender with no lives lost. This ended up not happening for probably several reasons, but one of them was the concern that something would go wrong and the bomb would fail leaving the US looking stupid. Also, since so much money had been spent in the US developing these weapons, many in power felt that the American public and politicians out of the loop would feel that money had been wasted unless it was used directly in the war against the enemy.
I feel like the Soviets had a huge impact on this decision as well. Similar to Europe, by 1943, it was pretty clear that the Allies would win against Japan, it just a matter of how and when.
For most of the war, the Navy and proponents of Air power claimed that the war could be won by systematically wearing down Japan through a substantial bombing campaign and submarine blockade. While the bombing campaign failed in that it did not break the government's will to fight, forcing them to surrender, the Navy's submarine campaign was extremely successful, albeit doing so without much recognition. Unlike the German U-Boats, they were able to successfully cut off an island nation from its overseas resources, effectively starving it. However, in the end, US leaders recognized this approach would be less than satisfactory for two reasons:
1) There was no guarantee the Japanese leadership would surrender, even as millions of their people starved, and their factories ground to a halt without necessary materials, meaning the war would be dragged on needlessly, and possibly leading to an even greater loss of life for the Japanese.
2) The entrance of the Soviet Union into the war meant that the US no longer had the luxury of time, as with the fall of Hitler, it was clear that Stalin was the greatest threat to people across the globe, and that they could not afford to let him expand his influence further in Asia, specifically in Japan (No one wanted to see Japan divided into zones of occupation like Germany).
Detonating a bomb as nothing more than a display would also have been an extremely risky maneuver, even if it were to work, since there was no guarantee that it would force a surrender, and it wasn't as if the US had plenty of Atomic weapons laying around at that point.
In the end, I feel like it came down to looking forward to the Cold War that figured into the decision to use the bomb more than anything else.