Masechet Avot, Perek Heh, Mishnah Bet. Mishnah says, “Asarah dorot me'Adam ve'ad Noach, lehodia kama erech apayim lefanav.” The Torah lists 10 generations from Adam all the way to Noach in order to teach us how patient Hashem was. The Torah is not simply a history book telling us who lived here and where and what, but the Torah is making a point by listing the 10 generations from Avraham all the way through Noach to tell us that Hashem is patient with wicked people. “Shekol hadorot hayu mach'isin uva'in.” All the generations here, they angered G-d more and more. “Ad shehevi aleihem et mei hamabul (the Flood).” Until eventually Hashem brought the waters of the Mabul. Hashem could have destroyed mankind immediately. Once the first generation or second generation did evil, Hashem could have wiped them out. But Hashem is not like that. He gives mankind the chance to do Teshuvah (repentance). But eventually there's a limit to it as well, and Hashem decided to bring the Mabul after 10 generations of patience.
“Asarah dorot miNoach ve'ad Avraham.” There are 10 generations from Noach until Avraham Avinu (our father), which the Torah also informs us about: “lehodia kama erech apayim lefanav,” to also tell us and emphasize that Hashem is patient. “Shekol hadorot hayu mach'isin uva'in.” Because all the generations here as well caused more and more anger to Hashem. You would think that once the Mabul happened and people learned their lesson, they would get better, but we're creatures of habit, unfortunately, and people get back in their evil ways. And they continued to sin before Hashem. “Ad sheba Avraham vekibel sechar kulam.” Until Avraham Avinu came and took the reward for all of them. All of these generations were wicked, but Hashem would rather not destroy the world, but rather have the world return to Him through Teshuvah, through repentance, and that's exactly what Avraham Avinu did. His merit decided to save all of mankind. He was a righteous person, and he brought others onto the way of HaKadosh Baruch Hu.

