Japan and the Soviet Union shared a common border in Manchuria and the German invasion of the Soviet Union weakened the Soviets greatly. In view of the advantages to Japan in seeing the Soviet Union defeated (not to mention the resources available in Siberia) and the fact that Japan had large Kwantung Army stationed there essentially doing nothing, why didn't Japan attack?
We have to delve into two spheres to address this question, the political and the military.
Militarily, the Japanese fought a series of border skirmishes with the Soviet Union at Khalkhin Gol (located along the Manchurian - Mongolian border, Mongolia then being a "People's Republic" and puppet of the Soviet Union) through early summer to early autumn 1939, with the main battle happening on August 20th-31st. Georgy Zhukov (who later went on to lead large formations in Europe, but then a Corps Commander) launched a coordinated combined arms attack which stunned the patently inferior Japanese, leading to a prompt ceasefire and cessation of hostilities on September 15, 1939.
Politically, the Japanese military cadres were always divided along two opposed doctrines: the Northern Expansion Doctrine (in which the Japanese Empire would expand north into Siberia) and the Southern Expansion Doctrine (in which the Japanese Empire would instead focus on South-East Asia and the greater Pacific) favored by the Army and Navy respectively. The thorough paddling that the Imperial Japanese Army and the Kwantung Army received at Khalkhin Gol discredited the Northern Expansion Doctrine.
There are indications that the Japanese would have struck the Soviet Union had Operation Typhoon succeeded and Moscow taken by the Germans, but this obviously never materialized. What a difference 50km can make!
Japan was interested in extending its influence in Asia and for that it had to confront either USSR or USA. While I don't think that the exact reason for choosing USA is known, Japan was at a clear disadvantage when battling USSR: while the Soviet Union had established overland supply line for its troops in the far east (Trans-Siberian Railway) the Japanese had to supply their troops and transport reinforcements by sea. This already proved fatal for Japan in the Russo-Japanese War and only the civil unrest in Russia that eventually led to the 1905 Russian Revolutiоn saved Japan from a defeat. The history repeated itself in the Battles of Khalkhin Gol in 1939 and I guess that the Japanese learned their lesson.
The United States on the other hand could only defend their interests in Asia and Pacific by sea, same as Japan itself. So the chances here were equal and the attack on Pearl Harbor temporarily gave Japan a significant advantage - something that they couldn't achieve against Soviet Union.
The Soviets kept a strong army in the Far East at all times, in case of Japanese attack, and the Japanese had come out a distinct second best in earlier battles. Opening up a front meant committing the Kwantung Army to battle, with all the logistics (never Japan's strong point) that implies, and a battle that the Japanese could not necessarily pull back from.
Further, there weren't all that many resources being exploited in Siberia, and Siberia's a very big place. After what was available near Manchuria, it was a very long trip to the Irkutsk area, the next place worth conquering.
One important reason that Japan chose to go to war with the United States rather than the Soviet Union was because its navy was the stronger of its two arms.
The Japanese navy was quite competitive with the U.S. navy, even before Pearl Harbor (until the 1943 U.S. shipbuilding program kicked in). Not so the Japanese army, which had been defeated by Soviet forces on the Mongolian border in 1938, and lacked tanks and other heavy equipment.
Furthermore, Japan didn't have the logistics to fight a "two front" war, one on land and one at sea.
They had a treaty beginning in 1941, after a few skirmishes along the area in question. They were also a member of the Tripartite Pact, which they remainded a member of even after Germany attacked the Soviet Union
US oil sanctions were crippling Japan and they came after the US to try and force FDR into negotiations and cripple our Navy that he had moved from San Diego to Honolulu, the only force capable of stopping the Japanese from taking the oil fields in the Indies. In other words they were desperate for oil and had to remove the threat of the US Navy before they could think about war with Russia.
In August 1939, while Japan and the USSR were skirmishing, Germany and the USSR signed a Non-Aggression Pact that allowed Stalin to put some more focus on Japan (among other things). By early 1941, Japan decided it was time to focus on securing its oil supply in Indonesia and so shifted to its Pacific strategy. Hence they signed a neutrality pact with the USSR in April 1941. Germany showed no signs of a policy shift until June 22, 1941, when it abruptly attacked the Soviet Union.
With regard to the USSR, Germany was like "we got this." All through 1941 while Japan was prepping Pearl Harbor, Germany was wailing on Russia. When Pearl Harbor happened, the Wehrmacht was at the gates of Moscow. The Nazi leaders were debating whether to start killing the Jews right away, or "in the spring, after the war" meaning 1942. Likewise, Japan expected its expansion in 1941-42 to present the West with a fait accompli, that the USA would have neither the resources nor the willpower to fight, and that if they did, it would take several years to recover from Pearl Harbor and present a new threat in the Pacific. In other words, they could focus on China, and the USSR if they wanted, later. It did not work out that way.
They did attack the USSR a few times, but lost badly and decided to sign a treaty with the USSR. They quit with Russia because they wanted to expand farther into the Pacific to which Russia wasn't a threat to that goal. That's perhaps the biggest reason for the Raid on Pearl Harbor, Japan was worried that America would intervene and cause issues to the plan. They decided to launch a first strike to neutralize the possibility, by destroying the American fleet and holding us off for awhile. This however didn't happen because the main targets being our aircraft carriers were out to sea at the time of the attack.
The Invasion of Pearl Harbor ,History Channel
Imperial Japan WOULD have declared war on USSR had it been successful at Midway, as it was successful at Pearl and in invading Philippines. The US essentially kicked in the door to Japan at Midway. US had agreed to a "Europe first" policy with its European allies upon declaring war against both Japan and Germany. The problem is that European theater was simply not ready to utilize American forces.
After Midway, Japan was no immediate threat to the US, and US could have delayed further action against Japan for a considerable time, had we still had an essentially isolationist sentiment, simply because Europe wasn't prepared for US the brunt of US effort. That brunt most immediately went to the Pacific War. Had it not, Japan could have and may well have moved against the USSR. This was particularly opportune when the manufacturing capacity of USSR was packed up and moved by Stalin east, away from Moscow, and re-assembled closer to the eastern front.
An attack by Japan in the fall of 1942 was quite possible, since the USSR essentially had no defenses deployed on its eastern front, and the destruction of its mfg capacity would have doomed the USSR to the residual Nazi attack, and would have cost Japan very little, assuming the US had not advanced in the Pacific after Midway. Because the US did advance with all its might, Japan simply could never have mounted an attack on the USSR, even had it weakened or diminished its efforts in Burma, the Malay Peninsula, etc.
It has become popular in the past 20-30 years to credit USSR with defeating the Nazis, but this disregards the effect of the US' offensive against Japan in keeping the Japanese from opening a front against the USSR.
As was stated in another answer, there were a number of skirmishes/battles that occurred in 1939, such as the Battles of Khalkin Gol, but it essentially concluded when it became apparent that Japan was not a military match against the Russians. This basically guaranteed that Germany and Japan would never link up as allies on land.
For more information about the battle, I'm going to forward you to the Wikipedia article on Battles of Khalkhin Gol.
Japan tried to expand into China and South Asia. It had no condition to attack Russia in the North at the same time.
The Japanese primary strategy was to create an East-Asia Prosperity sphere of influence, including SE Asia, parts of China and Indonesia. This also fit in with their desperation for resources, especially oil (see, for instance, the book The Prize by Daniel Yergin). SE Asia also had bauxite for Aluminum refining (as did the Caroline Islands, see Aluminum Ore: The Political Economy of the Global Bauxite Industry) and Japan was also desperate for Aluminum imports, which had come from the U.S. but were cut off due to the bad press from Japanese atrocities in China. In many ways, the attack on Pearl Harbor was a distractions and disaster, and an attack on Russia would have been, also.
Japan and Germany had a political and military alliance during World War 2, as Japan was part of the Axis powers. When Japan attacked Pearl Harbor on December 7th, 1941, the U.S. declared war on Japan the following day. As you would expect, Germany (Japan's faithful ally) then declared war on the United States on December 11th, 1941. So yes, when Germany invaded the Soviet Union, it's puzzling that Japan did not honor its alliance by attacking the U.S.S.R. Such an arrangement would have divided the Soviet military in two and assured a victorious invasion for Hitler.
So, why on EARTH would Japan cross the Pacific to fight a neutral United States when its own ally was at war with neighboring Soviet Union?
Recent details have come to light that finally answer the question. In the mid 1990's, after the collapse of the Soviet Union, certain KGB archives revealed that Soviet spycraft actually engineered the war between the United States and Japan. This new information, stemming from the Venona Project, shows that Soviet penetration of the U.S. State Department and Treasury Department played a key role. Specifically, Harry Dexter White, a senior economist at the U.S. Treasury, was instructed to author key conditions during diplomatic exchanges between the U.S. and Japan. The key conditions were designed to start a war. The main condition was the demand that Imperial Japan withdrawn from all occupied territories This condition in particular convinced Japan that the U.S. was committed to war in the Pacific. In essence, Japan felt that they HAD to fight the United States. (Check out 'The Venona Secrets' by Herbert Romerstein & Eric Breindel as well as 'The Battle of Bretton Woods' by Benn Steil).
Once the Soviet Union was assured that their American agents had issued the hardline conditions, the Soviets could confidently focus on a one-front war instead of a two-front war. On December 4th, three days BEFORE the attack on Pearl Harbor, the Soviet Union confidently moved nearly all of its eastern land forces...forces that would have fought against Japan...into the western front to counter Hitler's fast-moving invasion. From a military standpoint, its dangerous to turn your back on the ally of your enemy (Japan) unless you are absolutely certain they will not attack.
Militarily, Japan had MUCH better chances fighting a country that was right next door and already heavily engaged in fighting Nazi Germany, which happened to be Japan's military ally. It is truly a miracle of statecraft that Japan was tricked into attacking a neutral nation nearly 3,000 miles away.
Also of interest...the Soviet Union, who was supposedly an ally of the United States in fighting Hitler...never declared war on Japan until AFTER the atomic bomb was dropped in 1945. After that, the Soviets moved their forces back to the east and promptly invaded Manchuria. Pretty nifty spycraft.