According to Nigel Rees in Phrases and Sayings, Miss Alice Lloyd was singing a music-hall song in November 1898 which contained these lines:
'You say you've never heard
How many beans make five?
It's time you knew a thing or two
You don't know you're alive! '
The phrase was also recorded 12 years earlier and seems to come from the heyday of Victorian humour.