Actually, the Japanese attack on Pearl Harbor was not only from the air. They also employed so-called midget submarines, although those were largely unsuccessful.
The vast majority of the attack was by air. The mastermind of the attack, Admiral Isoroku Yamamoto, decided that an air attack would provide the greatest damage to the US Pacific Fleet with the lowest risk to the fleet of the Japanese Imperial Navy. He was correct in that regard.
He also surmised that an air attack would be less likely to be detected than ships because the Zeros could travel faster. Again, he was correct.
Why didn’t Japan invade?
That was not part of Yamamoto’s strategy. His aim was to damage the US Pacific Fleet so badly that the morale of the American people would be devastated, and the US would quickly capitulate. In this regard he was wrong and the outcome was very different.
← Why did the Japanese attack only by air?