Well, that's what people usually get out of civil trials, and there's plenty of literature on how to go about quantifying the cost of the injury (though often it just comes down to a jruy's intuition).

Penal theory is a complex topic. The intellectual heavyweight on this topic from a philosophical standpoint is the late Michel Foucault, who wrote a book called Discipline and Punish studying the origin of the prison. It's not an easy read (I strongly suspect Foucault just banged out his first draft on a typewriter and then browbeat his publisher into printing it without any revisions) but an extremely thought-provoking one.

Basically his thesis is that in earlier times, most work was agricultural and lawbreaking was treated as tantamount to attacking the king of a country, so terrible retributions and tortures would be visited on the body of offenders in a way that was meant to mirror the (metaphorical) injury to the body of the monarch (which was the embodiment of society, law and so on). although such punishments were gruesome (and often had the unintended effect of creating sympathy or notoriety for criminals) they were not actually administered that often and there was actually a lot of wiggle room between what the law said and how it was enforced, which had the purpose of acting as a political safety valve while still making it easy to crack down on real threats (truly awful crimes, or waves of crime by rebellious mobs etc.).

At the dawn of the industrial age, the factors of economic production shifted away from land and towards other forms of capital, and manufacturing shifted away from skilled craftsmen in self-policing guilds towards factories and so on. The division of labor and specialization made organization essential, and first the workplace, then also schools, hospitals, and eventually prisons were reconstituted in the image of military camps, since standardization and deindividuation had long proved their worth in military conflict.

Foucault argues that organizing, quantizing, and generally systematizing the punishment of crimes led to an increasingly impersonal approach based on surveillance and the manufacture of compliant behavior as a social product (note, for example, the oddly anthropomorphic architecture of Pentonville prison, which was heavily influenced by Benthamite concepts of continuous surveillance: https://en.wikipedia.org/wiki/Restorative_justice#/media/Fil...). Insofar as this disciplinary approach became the norm across society as the middle class displaced the peasantry as the primary political force, so too it made society more and more neurotic and whole industries sprang up to manage and indeed optimize these neuroses. Further, establishment of prisons as a mainstream social technology practically guaranteed the dissemination of criminal knowledge between inmates, providing society with a way to extract value from criminal enterprises at the same time that expanding the scope of criminalization proved an effective tool for restraining whole sections of the population by channeling criminal energies into fairly predictable and manageable channels.

tl;dr by default, we're actually cogs in a big economic machine that molds our entire perception of reality. Various science fiction films like The Matrix make a similar argument in allegorical terms.