I think it's reasonably clear from history that the US was probably the prime main power against Japanese aggression from 1937 onwards (possibly even from 1931 when Japan took Manchuria)
1937 - Japan invades China - US actively supports China with loans and arms
1938/39 - Japanese bombing of Chinese civilians and the Nanking massacre provokes world outrage - US starts with 'moral embargo' of aircraft and related material. This is stepped up over time. Although not hurting the Japanese really, it effectively blanket bans all US exports of military material to Japan. Aviation gasoline is included in this embargo, but not oil in general - Japan at this time depends on US oil, about 80% of all oil is from the US. Embargo is later extended to iron and scrap.
1941 - Japan 'occupies' southern French Indochina meaning that the Dutch East Indies and British Empire assets are now easily within range of Japanese planes. The US leads the protests, calling for withdrawal and imposes a complete oil embargo, that the UK and the Dutch also impose.
So in the eyes of the Japanese what's happening and who is the biggest enemy in 1941?
- The Soviet Union looks like it's on the ropes and not wanting to provoke Japan to leap in and get involved with it's life and death struggle with Nazi Germany.
- The British Empire is also looking very vulnerable and also is not wanting to prod the Japanese to aggressive action.
- That leaves the US, the biggest other naval power in the Pacific as the main threat (and with the above actions detailed above, the Japanese see as directly threatening their military policy and nation.)
Now for a while the Japanese Prime minister, Prince Fumimaro Konoe, has been trying to broker a neutrality pact with the US - which essentially meant that Japan was to curtail aggressive acts, withdraw from China etc... Apart from the fact that the Military in Japan tend to disagree with having to do this and the deal was negotiated behind everyone's back, all such discussion really go out of the window after the occupying of southern Indochina (They continue of course but then's it all about trying to mislead the US about future intentions). They've been stockpiling oil, but I believe when the embargo comes in it's something like: the army has about 6 months of fuel for fighting, and the Navy has about 2 years maximum to maintain the fleets.
So the Japanese have a bit of a prisoners dilemma.
If they do nothing their campaign in China grinds to a halt, as does the rest of their industry and their fleet is on borrowed time. They will be forced to accede to US demands.
Or they go to war. Ideally they would like it if the UK or US are the aggressors, but it is highly unlikely that is going to happen. So their only other option is to declare war and to grab the oil for themselves to maintain their expansionist policies (by this time Tojo is prime minister and the military are in charge)
Now they could do a more limited campaign and take the Dutch oil fields and also all far eastern British assets (well the Dutch can't defend themselves and the British are occupied in Europe and Africa, and the Japanese are part of the Axis powers...) But what sort of response does this provoke from the US, they wonder?
I think they are convinced it will lead to the US declaring war on them. In fact as they are unlikely to accede to US demands to leave China alone, they probably see war with US as inevitable. So while they are occupied taking these the Dutch and British territories, they are frightened that the US fleet and armed forces would attack, so their thinking is, "Well if it's going to happen anyway, we should try and cripple the strongest enemy first, so that we have enough time to complete our conquests." In some ways this is not outlandish that US military action was coming. Roosevelt had moved the Pacific fleet from it's original anchorage of San Diego in early 1941 to Pearl Harbour and was beefing up the US forces in the Philippines.
Of course we don't know if the US would have declared war if Japan had only seized the Brits and Dutch territories. Being attacked at PH certainly made Roosevelt's job much easier.
Possibly also they had fantasies about Germany taking both the USSR and Britain out quickly and then Japan & Germany ganging up against the US - something that might have not looked outlandish in October 1941.
So after that essay, I'll give the one sentence reply: They thought war with US was inevitable so they tried to gain the upper hand, while their forces were strong, with a surprise attack.
As for how much the US actually knew about Japanese intentions, I believe the standard thinking is that the US thought there might be an attack of some form, just not on the Pacific fleet and the US. There are of course alternative explanations that had all of the high commands and political leaders of the UK and US knowing exactly what was going to happen and allowed it to shake the US out of its isolationist leanings, but I don't know if these theories have any legs.