Answer:
One reason is to hold criminals and keep them away from society, where they will do the least harm.
Another is simply to punish them.
Another is to attempt rehabilitation through education, training and opportunities for exposure to religion.
Another is to try to deter others from engaging in the same activities.
Another is to provide politicians a chance yo win votes by "being tough on crime."