There's no definitive origin story for this idiom, but here's how it likely developed:
* Literal meaning: The phrase originally referred to the practical need to save resources, like food or firewood, for when the weather turned bad and people couldn't easily go out to gather more. Rainy days were often associated with hardship and limited opportunities.
* Figurative meaning: Over time, the idiom transitioned to a more figurative meaning, symbolizing saving money or resources for a time of need or unexpected hardship. It's a reminder that times can be unpredictable and it's wise to prepare for the unknown.
While the exact origin is unclear, the phrase has been in use for centuries, with its earliest recorded appearance in the 18th century.