It's often used in a figurative sense to emphasize the abundance of something.
Examples:
* "There are more people here than you can shake a stick at."
* "They have a library with more books than you can shake a stick at."
* "We saw a whole herd of cows, more than you can shake a stick at!"
The origin of the phrase is unknown, but it's thought to have originated from the idea of trying to hit something with a stick, which would be difficult to do if there are many things to hit.