Why did Japan select Pearl Harbor, and not some other U.S. military base, as the site to surprise attack in 1941? Why didn't Japan attack, for example, the Philippines, or the Panama Canal, or Wake Island, or even California? Why did they select Pearl Harbor instead?
Pearl Harbour was (edit) the base where most of the US Pacific Fleet was deployed, and the intention was to attack the fleet in harbour. That was because ships that are stationary are much easier to hit with bombs and torpedoes. Staging the attack required knowing that the fleet was actually at its base, but that was hard to hide - ships are big and easy to see - and the Japanese had a consulate nearby that could make reports.
The point of the attacks was to cripple the Pacific Fleet and thus prevent it from interfering with the attacks that the Japanese intended to make on US possessions nearer to Japan (The Philippines, Wake Island and Guam were also attacked over the next few hours) and on British and Dutch possessions that were also attacked.
If the Pacific Fleet's aircraft carriers been present at Pearl Harbour at the time of the attack, they would also likely have been damaged or sunk. It was a matter of chance that they were away on missions.
Wikipedia has a decent overview of the reasons for the attack and an account of the action.
(edit) Any fleet going to attack the Panama Canal or California would have to be fairly small, so as to be able to take enough fuel along in tankers for the return trip. The obvious reason for not doing that is that the fleet would be intercepted by the US Pacific Fleet on its way back, and sunk. Attacking the Panama Canal effectively is tricky. Attacking California is pointless - you can't do damage that will cripple the US war effort. But destroying the whole Pacific Fleet at Pearl Harbour would cripple the warfighting ability of the USA. The Japanese attack was intended to do just that, but did not succeed.