My memory of Philosophy 101 was that it wasn't exactly logical. Considered from the point of view of human psychology and what we now know about the brain, 90% of it was crap.
Without society, every human is potentially in a state of war to the knife with every other human. In war to the knife there are no morals. Morality is an artifact of the nature of humans as social animals and as the particular kind of social animals we are. Morality is the codification of the unwritten rules of our animal self-interest in re the nature of our species, as modified by our learned strategies for adapting to our society.
According to your thesis, it would be immoral for a family to beat the crap out of a rapist and drive him off from their farm because it *might* not successfully deter him from coming back and raping the farmers' teenage daughter.
According to your thesis, it would be immoral for me to ground my child for stealing a toy from a friend's house on the grounds that she *might* not be rehabilitated by that punishment and *might* steal a toy again.
Reducto ad absurdum.
Q.E.D.--your thesis is wrong.
Rehabilitation, deterrence, and retribution all have the fundamental commonality that they are all in the self interest of society. As part of the social contract, humans cede the direct power to protect themselves from hostile people by avenging crimes to government *on the condition that* government use its power to do the best job of which it is reasonably capable to protect peacable citizens from those who are not peacable. People have the natural moral right to protect themselves from attacks on their person or property---by direct defense, preemption of a clear threat, or vengeance. Society claims the derived right to protect those people who aren't attacking others, to increase accuracy in identification and increase effectiveness of response.
Civilization makes laws against crimes not to make them "bad". By human nature, "malum in se" crimes are already things inimical to constructive group social function. We make laws against crimes to codify the procedure by which we identify people who are dangerous to those of the rest of society who are peacably minding our own business, and by which we determine how best to protect society from those identified individuals.
We have criminal laws not to make things crimes, nor even to punish crimes. We have criminal laws to formally identify forcibly or fraudulently dangerous people and deal with them, so that we avoid the damage to the innocent and other excesses of vigilantism.
Rehabilitation protects society from anyone successfully rehabilitated. A 75% or even 20% success rate is far better than a zero success rate. Deterrence protects society from anyone deterred. Again, even a 20% success rate of crimes deterred is better than a zero success rate. Retribution heals the victims by providing comfort and an emotional sense of justice after the fact.
Of course society's punishment of the guilty, according to the laws, by its best ability to discern the guilty from the innocent, is morally just----whether the punisment is targetted to rehabilitation, deterrence, or retribution.
All three of those things are things innocent people want, and that people who commit crimes that are malum in se have ample reason to know they face *before* they commit the crime.
It's moral because morality is the formal protection by each other of each other's natural rights in any society.
People in anarchy have the natural right to do their best to protect themselves from other people who attack them, to the best of their ability to determine guilt or innocence, and to use whatever methods they perceive to be most likely to protect or recompense them from threats against themselves.
Society has the derived moral right to exercise those same attempts at protection to the best of its ability to determine guilt or innocence and to the best of its ability to determine what response to the guilty (by society's best attempt to determine guilt) best protects its non-criminal (in that incident) members. Society's right derives from people delegating their own natural right to it in the interests of all people in society having an improved chance for justice.
Julie