Japan is a small country, and needed more land to get access to resources like oil and so on.
So, as has been said, they had already attacked china and other countries well before WW2 started (late 1930s).
Because of Japan aggression the US stopped supplying oil to Japan, which upset Japan, making them angry with the USA.
There were a lot of military leaders in Japan who were spoiling for a fight, and so they decided to attack Pearl Harbour to get one over on the USA (and destroy their pacific fleet before it could do any damage to Japan).
Of course all that did was bring the USA into the war (much to the benefit of the UK I might add) and make it a true World War