Why Japan Bombed Pearl Harbor?

Japan bombed Pearl Harbor because they wanted to take over the United States. However, eventually they lost the war after the US dropped two nuclear bombs in Japan.