The overall reason for this is that Japan wanted to have an empire in East Asia. They needed the empire as a source for raw materials and as a place for excess population to go and live.
The Japanese believed that the US would try to stop them from taking this empire and so they felt they would need to neutralize the US fleet to give them time to capture the empire.
When the US stopped selling them oil in 1941, they felt that they had to move soon before their stocks of oil ran too low. That is why they chose to attack Pearl Harbor -- to neutralize the US fleet so they could win an empire before their oil supplies ran out.
To increase Japan's expansionism, it was perceived the neutralizing the United States naval threat had to be accomplished. The perception was that the United States, in the midst of a challenging economic depression, would not respond with force and would be crushed by the attack. The element of surprise was with the Japanese. These motives of expansionist desires in the Pacific Rim and the perceived ability to silence the United States played into the Japanese desire to bomb the United States. Pearl Harbor seemed to be the perfect target because of its close proximity to Japan and a small distance for bombers to travel, and that military support would not be able to get to the island from the mainland in time.
A consensus had been reached from a series of imperial conferences that Japan would need to fight the US to obtain victory in Southeast Asia. To prevail in a protracted conflict, Japane needed high levels of raw materials and the only way to obtain the resources from Southeast Asia was to provoke the US into a war through a surprise attack. The attack on the US would give the Japanese the time they needed to attain the resources they required and to further expand its own industrial capability. It was thus necessary for the Japanese navy to first destroy the American Pacific fleet and challenge US naval supremacy since it was the only potent force that could halt the Japanese advance in the region. By destroying the battle fleets that were located at Pearl Harbour, Japan would be able to gain the time they needed to erect a giant barrier around Southeast Asia, which when guarded by the imperial navy, could keep the US at bay. A knockout blow at sea was also essential to gain the psychological ascendancy they needed to drag out the war so as to force the Americans out of it - they were sure that the Americans would not be invested into fighting a protracted conflict in a region that they would not familiar with.