The story
The figurative sense is by extension from the literal sense, which is threshing. Because threshing has been an important activity for humans for thousands of years, it is well represented both in folk wisdom and (relatedly) in the Bible; for example, Matthew 3:12.
Etymology from Wiktionary, CC BY-SA 4.0.