The Rock – perfect is His work, for all His paths are justice. A G-d of faith without iniquity, He is righteous and fair.
Be’er Yosef: Citing this pasuk, the gemara takes a dim view of those who believe that HKBH has a relaxed attitude towards sin. “Whoever says that Hashem overlooks sin, may his life by overlooked!” Rashi explains that such a position provides a license to others to sin, by minimizing the risk of punishment.
How could anyone reasonably believe such a thing? The Torah is full of warnings about an array of punishments to the individual and communal sinner! All the evidence points to Hashem taking aveiros very seriously.
We could try a different approach. It is clear that Hashem does – often – excuse our transgressions. The gemara perhaps criticizes the person who sees this as an exercise of unrestrained chesed and compassion, as if He at times simply dismisses His rules, and governs with compassion alone. This is not the case. Rather, on those occasions when He does suspend the ordinary rules, His chesed is fueled by justice arguments!
The gemara points to our pasuk. How can all His paths – meaning His midos – amount to justice? When He suspends strict judgment and applies mercy, for example, He does so to those who have some claim to mercy, i.e. to those who have incorporated His midah of mercy in their own lives. That creates a measure-for-measure justification for showing mercy specifically to those who have embraced that midah in their own conduct.
In the famous “prayer duel,” R Eliezer davened 24 berachos, but no rain fell in a time of need. R Akiva succeeded with two“Avinu Malkenus.” A heavenly voice cautioned against assuming that R Akiva must have been the greater tzadik. Not so, said the bas kol. Rather, R Akiva’s prayer was answered because he was more successful than R Eliezer in looking away from his own nature. In other words, the community did not really merit or deserve rain at that time. If fell only through Hashem’s overruling considerations of din and applying chesed instead. Still, this would not have happened without R Akiva becoming part of the calculus. Because he was a forgiving person, Hashem was able to implement His own forgiveness and apply it to the people. Another way of looking at this is that through R Akiva’s behavior, G-d’s “going beyond the letter of the law” became an exercise of law and justice!
A midrash speaks of a march of early figures who spoke up at the time of the destruction of the beis hamikdosh. Each one of them, beginning with the avos, pointed to his special zechus/ merit. None of their arguments were accepted. None that is, save for those of Rochel. Her merit was not greater than that of the avos. To counter and satisfy midas hadin, however, a justice argument was needed. Rochel, who had shown extraordinary chesed to her sister Leah, was able to provide that argument. The beis hamikdosh had been destroyed because of widespread avodah zarah. This idolatry had initially been conducted in private. Gradually it became more assertive, and spread to public areas, in the end entering the kodesh hakodashim itself. This precipitated great kinah against the emptiness of avodah zarah that usurped the role, as it were, of HKBH , and a gezerah to destroy the beis hamikdosh. It took specifically the selflessness of Rochel – her lack of jealousy, and her willingness to forego her role as wife to Yaakov in order to prevent the shaming of her sister – to counter this gezerah, and leave a place – in din! – for Hashem to employ compassion.
This, then, is the intention of the gemara. Whoever believes that Hashem casually disregards sin is in error. He does not choose to simply replace din with the midah of chesed. Rather, He reserves such replacement for situations in which mishpat itself calls for it, where justice itself argues for such a display of chesed.
 Based on Be’er Yosef, Devarim 32:4
 Bava Kamma 50A
 Taanis 25B
 i.e. in forgiving
 Eichah Rabbah, Pesicha