Specifically, in section 27, we find a powerful connection drawn between human sin and divine response, all through the lens of a verse from Ecclesiastes.

The verse in question is Ecclesiastes 2:23: “For all his days are pains, and anger is his concern; even at night his heart does not rest. This too is futility.” But what does this have to do with Genesis? The rabbis of the Midrash, in their characteristically ingenious way, saw this verse as a commentary on God’s reaction to human wickedness as described in Genesis 6:5: “The Lord saw that the wickedness of man was great on the earth.”

Who exactly are the "wicked men?" Well, the Midrash doesn't hold back.

First, the text identifies “the generation of Enosh and the generation of the Flood.” These were the people, Bereshit Rabbah says, who "would pain the Holy One, blessed be He, with their wicked deeds." It wasn't just that they were sinning; they were actively causing God pain. And not only during the day, but, as the verse says, "Even at night his heart does not rest" – meaning they didn't even take a break from their transgressions! The Midrash reinforces this, pointing to Genesis 6:5, which states, "And every inclination of the thoughts of his heart was only evil all the day.”

But here's where it gets really interesting. The Midrash flips the script. “Even at night his heart does not rest” – this, it says, refers to the Holy One, blessed be He! God didn't rest from bringing punishment upon them, day and night. The proof? Genesis 7:23: “He obliterated all existence.” Talk about a divine response. And as Matnot Kehunah points out, the verse "The rain was upon the land forty days and forty nights" (Genesis 7:12) further supports this idea of relentless divine action.

The Midrash then shifts its focus to the people of Sodom, infamous for their wickedness. Again, the same pattern emerges: they pained God with their deeds, angered Him, and gave Him no rest, even at night. And again, “Even at night his heart does not rest” is reinterpreted as referring to God's relentless punishment, culminating in the destruction of Sodom. Bereshit Rabbah 50:12 specifies that the punishment of Sodom occurred at the end of night and the beginning of day.

Finally, the Midrash turns its attention to the Egyptians. They too, pained God with their wickedness and angered Him. But in this case, the Midrash offers a more specific example of their cruelty: even after a long day of forced labor, the Israelite slaves were given more tasks to perform. The Egyptians allowed them no rest. Once again, “Even at night his heart does not rest” is applied to God, who relentlessly brought punishment upon them, culminating in the Exodus. As Exodus 12:29 states, "It was at midnight" that the final plague struck.

So, what’s the takeaway here? The rabbis of the Midrash, through their interpretation of Ecclesiastes, paint a picture of a world where human actions have profound consequences. Our choices, our deeds, can literally cause God pain and disrupt the cosmic order. But it's not just about punishment. It's about a reciprocal relationship, a divine response to human actions, a constant interplay between sin and consequence. It is a cycle of pain and anger, a cycle that, perhaps, we are still grappling with today. What does it mean to live in a way that gives God – and ourselves – a little more rest?