Q. Our Sages teach us that we should walk in HaShem’s ways. Just as He is merciful, so should we be? However, HaShem is also avenging. Why should we not also be avenging?

A. Horav Shlomo Miller’s Shlit”a opinion is that our Sages maintain that the punishments of the Torah and the ostensible acts of retribution or revenge of Hashem, are not in reality generally detrimental or damaging as we humans usually understand. They are rather qualified as a Tikun or a remedial process of healing and correction, that elevates a person and brings him back to his spiritual health and well-being. (Ramban – HaEmunah V’haBitachon, Shloh- Torah SheBal Peh 60, Beis Halevy – Vayero p.29, Ginas Verodim – k. 1, Maharsho – Sanhedrin 64b) It is indeed in that sense that we should strive to emulate Hashem when permitted.

Rabbi A. Bartfeld as revised by Horav Shlomo Miller Shlit”a