He said, “I will not destroy if I find there forty-five.” (Genesis 18:28)
Rashi explains that the significance of the number forty-five in this passage:
Sodom was a metropolis, with a total of five cities collectively referred to by the name “Sodom,” as it was the most eminent of the group. If there would be forty-five Tzaddikim (righteous people), this would mean there is an average of nine Tzaddikim spread over each of the five cities. If Hashem would then join with each group of nine, together there would be a quorum of ten for each city, and they would merit being spared from destruction.
Our verses says that Hashem “will not destroy” for the sake of forty-five Tzaddkim. The implication here is that this term leaves open the possibility that they could still receive punishment, albeit something short of destruction.
However, in the very text of the next sentence in the Torah (verse 18:29), Hashem says “I will not act on account of the forty” which implies that He’d neither bring punishment nor destruction on them!
The question is: Why should the presence of forty righteous individuals be more meritorious and a greater shield than forty-five?
The Meshech Chochmah, a classic Torah commentary, answers as follows:
When dealing with the prospect of forty-five Tzaddikim, that means that each individual person in every city was liable for not becoming the tenth righteous inhabitant of that city and bringing it up to a quorum of Tzaddikim! And for this they were open to punishment (but not destruction).
However, when it came to the possibility of forty righteous, that would mean there were an average of eight righteous per locale, so each individual was not as much on the hook for not becoming who he had the potential to be. And so, with forty righteous, there was no punishment and no destruction.
The ultimate takeaway from this passage is that the bigger difference you can make in the world, the greater the potential Onesh (punishment) for failing to become great and maximizing your potential!