The story
Hay harvest can be spoiled by wet weather. It is important that farmers seize the opportunity of dry weather for haymaking tasks (cutting, drying, gathering), more so in medieval times, when forecasting the weather was more difficult. Attested since 1546, originally a Tudor expression, and used figuratively since 1673.
Etymology from Wiktionary, CC BY-SA 4.0.