Corporal punishment as a penalty for crimes can have various forms: flogging, exposure to public abuse, branding, amputation. All are intended to physically humiliate the condemned, to cause physical pain. The intention seems to be that the fear of pain will act as a deterrent to crime, and that physical chastisement will motivate the condemned to reform.
Corporal punishment is an abomination. Replacing it with incarceration marks a significant moral advance.
It is possible that there are cathartic benefits for society to be derived from a spectacle of extreme savagery, such as a public flogging. In the calculus of cruelty, the gentler rigours of the penitentiary may count as a regression, since to be perpetually under surveillance for a long period may be worse than to be tortured.