The etymology of 'punishment' gives us its underlying meaning.

The word derives from the Greek 'poine' and its latin derivative poena, which mean revenge. In its capitalized form, Poine was the Greek Goddess of revenge. Poine and poena are also the roots of our word 'pain,' as well as of penalty, penal (system), penitentiary and penance. Hence, punishment is the infliction of pain on another for the sake of attaining revenge, er, I mean justice.