Depends. Some penal systems are there for "retribution" or punishment, and those match your definition. Other concepts available are rehabilitation and simply separating proven dangerous elements from society at large. Apart from the loss of freedom of movement (which I would not describe as "severe psychological distress"), there is no hard requirement for a prison system to be even unpleasant.