Actually the Japanese attack on Pearl Harbor was not only by air. They also employed midget submarines, which were largely unsuccessful.
However, the attack was mainly 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 correct.
So why didn’t Japan invade?
That was not part of Yamamoto’s strategy. His purpose was to annihilate the US Pacific Fleet so badly that the morale of the American people would be damaged and the US would quickly capitulate. In this regard he was wrong and the outcome was different.
← Why Did the Japanese attack only by Air?