|Art: Jacek Yerka|
The Flood came to purify the earth... because the earth had become filled with robbery and corruption to the extreme and required purification.
It was for this reason that the flood waters came for forty days, like a mikveh [ritual bath] which must contain a minimum of 40 se'ah of rainwater if it is to purify the ritually unclean.
Thus, for the generation of the Flood, the waters were a punishment, but for the world itself, the waters were a blessing, since the world became blessed through them.
This sheds light on the Torah's statement that the waters were both mild ''rain'' [of blessing] [Noach 7:12] and at the same time torrential flood waters [Noach 7:17] for even though the floods destroyed all the inhabitants of the world, they still had the positive effect of cleansing and purifying physicality itself.
Source: Based on Likutei Sichos vol 25 pp 26-27 Lubavitcher Rebbe