Origin of "More X than you can shake a stick at"
Solution 1:
"More X than you can shake a stick at" means more than you can count. I don't know the origin but a as a wild speculation picture someone using a walking stick or cane to count something. If there's lots to count, the stick will be shaking a lot for each item. If there's too much, the shaking stick won't be able to keep up.
The OED says it's a figurative use of shake but doesn't give any more on the origin other than saying it's colloquial, originally and chiefly U.S., and giving the same 1818 as in the question.
It's originally North American, but it is now commonly used and understood in the UK as well.
I found an earlier example from 1794, but without the comparative "more X than...". British Synonymy: or, An Attempt at Regulating the Choice of Words in Familiar Conversation, Volume 2 by Hester Lynch Piozzi:
THE explanation here is necessary, because the two last verbs are of an active signification, and often used as such ; to shake a stick at you for example, or shiver the glasses all to pieces ; in such sense they are not synonymous with the three first.
But this is British and the full phrase appears to be American, so they may be unconnected.
World Wide Words is usually a good source on these things. If they summarise: "nobody knows for sure", then that's probably the best we have.
However, there is this from alt.english.usage FAQ that questions whether the original meaning was different to today's:
This 19th-century Americanism now means "an abundance"; but its original meaning is unclear. Suggestions have included "more than one can count" (OED, AHD3), "more than one can threaten" (Charles Earle Funk), and "more than one can believe" (Dictionary of American English). No one of these seems easy to reconcile with all the following citations: "We have in Lancaster as many taverns as you can shake a stick at." (1818) "This was a temperance house, and there was nothing to treat a friend to that was worth shaking a stick at." (David Crockett, "Tour to the North and Down East", 1835) "Our queen snake was [...] retiring, attended by more of her subjects than we even dared to shake a stick at." (1843) "I have never sot eyes on anything that could shake a stick at that." (= "set eyes on anything that could compare with that", 1843) "[...] Uncle Sam [...] has more acres than you can throw a stick at." (1851) "She got onto the whappiest, biggest, rustiest yaller moccasin that ever you shuck er stick at." (1851)
A connection with the British expression "hold (the) sticks with", meaning "compete on equal terms with" and attested since 1817, is not impossible.
OED staff told me: "The US usages in DAE do appear to have a different sense to that given in OED. [...] All the modern examples I've found on our databases conform to OED's definition so I think this is still the most common usage."
Merriam-Webster staff opined that the "count" interpretation "works as well for 'as many as you can shake a stick at' [...] if you take it to mean that there is no limit to how many of the objects in question one could shake one's stick at. [...] We would consider 'A can't shake a stick at B' a different expression entirely, with a meaning similar to 'A can't hold a candle to B' [...]."
In their 1897 work "A Dictionary of Slang, Jargon & Cant", Albert Barrere and Charles Leland suggested that Dutch immigrants originated the expression using the Dutch word "schok" = "to shake or hit."
Solution 2:
Some early quotes that might shed a little bit of light.
(1833) There are more rules than you could shake a stick at before your arm would ache
(1833) ...then run into a great picture room and see more fine pictures than you could shake a stick at in a week...
(1847) ...I've got more children of one sort and another, than you can shake a stick at in a century...
(1855) ...more reputations slaughtered than their devils 'could shake a stick at' in twenty-four hours.
(1857) ...more peddlers round the country than you could shake a stick at in a month...
These have time adverbials following, something which is not seen in later quotations. My best guess is that shake a stick at was a way of saying "count with a stick." This meaning could conceivably be related to shake a stick at meaning "to threaten with a stick," which is attested at least as far back as the 1700's.
One longer quote from 1833:
I tell ye -- cute as nutmeg -- brought up on ten-penny nails, pynted at both eends; why that air hat o' his'n' t you see there, with a new hat-case, bran fire new, see how he keeps muchin' it -- whenever you look that way; why that's nothin' after all but an old three quarter dollar swap, with the wool off, an' more spots on the brim than you could try out in half a year -- No! As true as you're alive -- or shake a stick at between now an' everlastin'
Solution 3:
One harvests bushes full of berries with a stick, by shaking or thrashing the berry bushes with a stick. I believe it implies abundance. One doesn't shake a bush with only a few berries with a stick, one simply picks them individually. My guess is that this method of harvesting an abundant crop is the origin of the term. More than one could harvest.