The piano that Bartolomeo Cristofori first invented in Italy had only 54 keys. As piano music developed and evolved, the keyboard compass was gradually expanded in response to requests from composers who sought a broader potential for expression.
By the 1890s, today’s modern keyboard had become established with 88 keys spanning 7 ¼ octaves. These produce frequencies from 27.5 Hz to 4,186 Hz (4.186 kHz) when A is tuned to 440 Hz. (The pitch of the individual keys will vary depending on the tuning method.)
The human ear can hear sounds in the range from approximately 20 Hz to 20,000 Hz, but the upper limit of frequencies that the human brain can discriminate is at the very most around 4,000 Hz. Even if the compass were to be expanded by increasing the number of keys on the piano, the extra notes at the bass end would, to the human ear, sound like nothing more than a rumbling noise, and the added treble notes would be heard as an unpleasant dissonant noise with no sense of being in a tonal range, and thus, musically, would be almost meaningless.
It’s true that, today, some manufacturers are making 97-key pianos to special order, with nine additional keys in the bass segment of the keyboard. However, the strings for these nine keys in the lowest bass segment are really only there to provide a richer sound when other keys are played by resonating along with them. In reality, the extra keys themselves are almost never played directly.
And now you know why most pianos have only 88 keys!