In his introduction to Dante’s Inferno, Lino Pertile, an Italian linguist and Professor of Romance Languages and Literature at Harvard University, writes:
Two general conditions apply to all the souls in Hell: their deprivation of the sight of God, and the perpetual torment which each soul (with the exception of those in Limbo, who suffer only the first condition) must undergo as a punishment for his or her sin. The principle which determines the form that this second type of suffering takes is called by Dante the “counterpass” or contrapasso. With this term (from the Latin contra pati) Dante sums up the retributive principle, which establishes that every soul must suffer (Latin pati) in the afterlife according to the sin he or she has committed on earth. . . .
As a principle of justice, the contrapasso derives from the biblical law of retaliation (lex taliones) which required that “anyone who inflicts an injury on his neighbor shall receive the same in return” . . . . What distinguishes its appearance in the Comedy is that, in the poem, it does not function merely as a form of divine revenge, but rather as the fulfillment of a destiny freely chosen by each soul during his or her life. In the Comedy the state of the souls after death does not seem to have been devised and enforced by an external agent; rather, it seems to be “a continuation, intensification and definitive fixation of their situation on earth.”
— The Cambridge Companion to Dante, edited by Rachel Jacoff