to wave arms or legs wildly and uncontrollably, or to thrash about; as a noun, a tool with a weighted end on a handle used for threshing grain.
From Latin 'flagellum' (whip, scourge). The noun sense (farming tool) came first in medieval times; the verb sense evolved later from the flailing motion of the tool.
The flail was a brutal medieval weapon as well as a farming tool—the same design worked for both threshing grain and hitting enemies. Watching someone flail around in panic still evokes that whipping, out-of-control motion that the medieval tool embodied.
Complete word intelligence in one call. Free tier — 50 lookups/day.