Good explanations here based on the teaching of Saint Thomas Aquinas.
Catholic Answers, Karlo Brousard; Critics of the doctrine of hell often argue that it’s unjust, because eternal punishment exceeds the temporal nature of a mortal sin. Why should any sin we commit on earth, in time, require everlasting punishment in hell? It’s not proportional.
St. Thomas Aquinas responded to this objection by saying that the measure of a punishment is not determined by the duration of the fault, but rather by its gravity. And since for Aquinas a mortal sin “in a certain respect is infinite,” being committed against God, he concludes that “a punishment that is infinite in duration is rightly inflicted for mortal sin.” Read full article here.