Another interpretation (of Ecclesiastes 2:2): "Of laughter I said: It is mad!" How confused was the laughter that the attribute of justice laughed over the generation of the flood, [for it is written] (Job 21:10): "His bull breeds and does not fail," etc.; (Job 21:11): "They send forth their little ones like a flock, [and their children dance about]"; (Job 21:12): "They take up [the] timbrel and harp," etc.; (Job 21:13): "They spend [their days] in prosperity." Since they said (Job 21:15): "What is the Almighty that we should serve Him?" the Holy One, blessed be He, said to them (Ecclesiastes 2:2): "And of rejoicing, what does this do?" By your lives, I am destroying your memory from the world, [for it is written] (Genesis 7:23): "And He wiped out all that existed."
When Divine Justice Laughed Over the Generation of the Flood
Midrash Tanchuma Buber, Achrei Mot 2:3
ד"א לשחוק אמרתי מהולל. מה מעורבב היה השחוק ששחקה מדת הדין על דור המבול, [דכתיב] שורו עיבר וגו' (איוב כא י), ישלחו כצאן עויליהם (שם שם יא), ישאו (תוף) [בתוף] וכנור וגו' (שם שם יב), יבלו בטוב [ימיהם] (שם שם יג), כיון שאמרו מה שדי כי נעבדנו (שם שם טו), אמר להם הקב"ה ולשמחה מה זו עושה, חייכם אני מאבד זכרוניכם מן העולם, [דכתיב] וימח את כל היקום (בראשית ז כג).