The story
First use appears c. 1857 in a poem by the Scottish poet Alexander Smith. Used as an example both of an activity so simple that almost anyone could do it and of an activity so pointless that only a fool would do it.
Etymology from Wiktionary, CC BY-SA 4.0.