It is, of course, impossible to know for sure, but I would argue that it was necessary for Japan to attack Pearl Harbor.
For it to have been unnecessary, two conditions would have to have existed. First, Japan would have had to plan not to attack the Philippines. Any attack on the Philippines would likely bring war just as the attack on Hawaii did. Second, the US would have had to ignore Japanese expansion into areas like Indonesia and New Guinea. That way, Japan would not have needed to neutralize the Philippines or Pearl Harbor.
Since the US was strongly opposed to Japanese expansion, it is hard to imagine that it would have stood idly by as Japan expanded. However, it is not outside the realm of possibility.