Japan attacked Pearl Harbor in retaliation against the United States for cutting off Japan's oil supplies.
The conflicts that became "World War II" began in the 1930s with Japanese imperial aggression into Manchuria, to take over Chinese territory. Beginning in 1938, the United States adopted increasingly severe trade restrictions against Japan in response. When Japan moved into French Indochina in 1941, the USA froze all Japanese financial assets in the USA and placed an embargo on all oil and gasoline shipments to Japan. The Japanese viewed the embargo as an act of war, and their attack against the US at Pearl Harbor was (from their viewpoint) a response to US trade sanctions against them.