The phrase “to know beans” is usually in the negative; one who doesn’t know beans is appallingly ignorant or is wholly unacquainted with the subject under discussion.
It is likely that the expression arose from some story that went the rounds in America early in the nineteenth century, but, if so, the story has been lost.
It is possible, however, that it arose from some dispute over the cowpea, which, despite the name, is more nearly related to the bean than to the pea and which is often called either the black-eyed bean or the black-eyed pea.
But, as Walsh suggests, it is more likely that the reference was to the famous city of Boston, “the home of the bean and the cod,” the city of culture, the hub of the universe, where it would be a mark of the sheerest ignorance not to know that Boston baked beans, to be fit to eat, must be made of that variety of small white bean known as “pea bean.”
It might be, of course, that this American expression was contracted from the British phrase, “to know how many beans make five, a silly saying that probably got started several centuries ago by having children learn to count by using beans.
When little Cecil got far enough advanced to know how many beans made five, he was very intelligent and well informed, which is what the phrase means.