[Another interpretation (of Ecclesiastes 2:2): "Of laughter I said: it is mad." How confused was the laughter, when the attribute of justice laughed over the people of Sodom! (Job 28:5–8:) "As for the earth, out of it comes forth bread; but underneath it is overturned as by fire. Its stones are the place of sapphires, etc. No bird of prey knows the path, etc. The proud beasts have not trodden it, etc." Once they said, "Let us make the foot forgotten from our midst," as it is written (Job 28:4): "He breaks open a shaft away from where people sojourn; those forgotten by the foot, etc." — the Holy One, blessed be He, said to them (Ecclesiastes 2:2): "And of rejoicing, what does this do?" By your lives, I will make you forgotten from the world! This is what is written (Genesis 19:24–25): "And the Lord rained down upon Sodom and upon Gomorrah brimstone and fire, etc.; and He overturned those cities, etc."]
Divine Justice Laughs Over Sodom in Tanchuma Achrei Mot
Midrash Tanchuma Buber, Achrei Mot 2:4
[ד"א לשחוק אמרתי מהולל. מה מעורבב השחוק ששחקה מדת הדין על אנשי סדום, ארץ ממנה יצא להם ותחתיה נהפך כמו אש (איוב כח ה), מקום ספיר אבניה וגו' (שם שם ו), נתיב לא ידעו עיט וגו' (שם שם ז), ולא הדריכוהו בני שחץ וגו' (שם שם ח), כיון שאמרו נשכח את הרגל מבינותינו, דכתיב פרץ נחל מעם גר הנשכחים מני רגל וגו' (שם שם ד), א"ל הקב"ה ולשמחה מה זו עושה, חייכם שאשכח אתכם מן העולם, הה"ד וה' המטיר על סדום ועל עמורה גפרית ואש וגו' ויהפוך את הערים האל וגו' (בראשית יט כד כה) ].