There has been a long- standing debate on why the atomic bomb was used to defeat Japan. The threat of Russian advancement in Europe and in Asia was enough to worry the top officials in the United States and British governments. Wherever Russia would go, they would conquer that area for themselves. The imminent invasion of mainland Japan and the allied casualties that came with it were also a factor in the decision to drop the bomb.
If the allied forces had invaded mainland Japan, many lives on both sides would have been lost, probably more than there lost in the bombing of Hiroshima and Nagasaki put together.
The tactics that the allies had used up to this point cost hundreds of thousands of lives on both sides. This was when the Japanese only had maybe two or three thousand men on an island; whereas on the mainland millions of people would fight until their death to protect their country. Can you imagine if the Americans invaded mainland Japan, where they had not only soldiers to fight against but also the citizens of Japan? Massive destruction, immense loss of life, and the prolonging of the war until late 1946, would result to invading on foot instead of using the bomb.
Revenge also played a role in the decision to bomb Japan. The Japanese were not following the Geneva Convention in regards to treatment of prisoners of war. This document says that prisoners are not to be put through torture of physical or psychological nature.
The Japanese refused to comply that and would decapitate American prisoners, or shove bamboo shoots under their fingernails. The American government also wanted revenge for the surprise attack on Pearl Harbor.
The Russia territorial expansion definitely played a factor in the dropping of the bomb. The Soviet Union had already taken Poland and many other countries during the war. The Soviets were helping the Chinese with the war against Japan and would later get the railroads in China and Manchuria when Japan completely surrendered. The Americans did not want Russia to get involved in the war against Japan.
The most obvious reasons would be to prevent the Russians from expanding and to keep them out of Japan where they would hamper the peace process and gain even more territory.
Fortunately the Americans won the race of discovery, by using the atomic bomb. The United States proved their superior weapon power the Soviet Union and the rest of the world. The dropping of the Bomb on Japan was not entirely to halt Soviet expansion although it did play a role. .