The attack on Pearl Harbor happened because the Japanese wanted to destroy the U.S. Pacific Fleet so it could not impede Japanese expansion through the South Pacific. Japan also hoped to shatter the morale of the United States to prevent it from entering World War II.
Japan badly needed resources, such as rubber from Malaya and oil from the Dutch East Indies. Although the United States had been responding to Japanese aggression diplomatically, with embargoes of various goods to Japan, the Japanese administration felt that the United States could react militarily to further expansion. In Japan's estimation, an attack on the Pacific Fleet, coupled with an assault on the U.S.-held Philippines, would weaken the United States enough to keep it out of the war. President Franklin Roosevelt had recently moved the Pacific Fleet to Hawaii from San Diego, creating a tempting target for the Japanese.
Just before the Pearl Harbor attack, the United States and Japan had been involved in negotiations over Japanese withdrawal from China. When agreement could not be reached, the United States imposed an embargo on oil to Japan. At that time, Japan received 80 percent of its oil from the United States, so acquiring the oil fields of Brunei in the Dutch East Indies was a key to its continued expansion. Because the U.S. territory of the Philippines was in the way, Japan saw war with the United States as inevitable.