Personally I consider justice as the goal of criminal justice. That's admittedly a subjective thing, deriving most of its weight from the values a given society holds in common, and even then varying greatly from one individual to another. Personally, I think the principle of "take something, give something" is a good place to start. It's a principle of moral parity.
Things like protecting society and deterrence should also be considered, as well as things like mercy and forgiveness.
On the question of making rehabilitation a goal, I'm swayed by C. S. Lewis's argument against:
According to the Humanitarian theory, to punish a man because he deserves it, and as much as he deserves, is mere revenge, and, therefore, barbarous and immoral. It is maintained that the only legitimate motives for punishing are the desire to deter others by example or to mend the criminal. When this theory is combined, as frequently happens, with the belief that all crime is more or less pathological, the idea of mending tails off into that of healing or curing and punishment becomes therapeutic. Thus it appears at first sight that we have passed from the harsh and self-righteous notion of giving the wicked their deserts to the charitable and enlightened one of tending the psychologically sick. What could be more amiable? One little point which is taken for granted in this theory needs, however, to be made explicit. The things done to the criminal, even if they are called cures, will be just as compulsory as they were in the old days when we called them punishments. If a tendency to steal can be cured by psychotherapy, the thief will no doubt be forced to undergo the treatment. Otherwise, society cannot continue.
My contention is that this doctrine, merciful though it appears, really means that each one of us, from the moment he breaks the law, is deprived of the rights of a human being.
The reason is this. The Humanitarian theory removes from Punishment the concept of Desert. But the concept of Desert is the only connecting link between punishment and justice. It is only as deserved or undeserved that a sentence can be just or unjust. I do not here contend that the question ‘Is it deserved?’ is the only one we can reasonably ask about a punishment. We may very properly ask whether it is likely to deter others and to reform the criminal. But neither of these two last questions is a question about justice. There is no sense in talking about a ‘just deterrent’ or a ‘just cure’. We demand of a deterrent not whether it is just but whether it will deter. We demand of a cure not whether it is just but whether it succeeds. Thus when we cease to consider what the criminal deserves and consider only what will cure him or deter others, we have tacitly removed him from the sphere of justice altogether; instead of a person, a subject of rights, we now have a mere object, a patient, a ‘case’.
[...]
It is, indeed, important to notice that my argument so far supposes no evil intentions on the part of the Humanitarian and considers only what is involved in the logic of his position. My contention is that good men (not bad men) consistently acting upon that position would act as cruelly and unjustly as the greatest tyrants. They might in some respects act even worse. Of all tyrannies a tyranny sincerely exercised for the good of its victims may be the most oppressive. It may be better to live under robber barons than under omnipotent moral busybodies. The robber baron’s cruelty may sometimes sleep, his cupidity may at some point be satiated; but those who torment us for our own good will torment us without end for they do so with the approval of their own conscience.
http://www.angelfire.com/pro/lewiscs/humanitarian.html