While there are other goals in incarceration, I would have to say that today, in the United States, punishment and incapacitation are the primary goals. The other reasons that we incarcerate people are to rehabilitate them and as a means of crime prevention by example, showing people that crime results in incarceration, thus persuading people to not commit crimes.
We have become a spectacularly punitive culture, and in particular, we punish the crimes of those who are poor and otherwise disenfranchised to a greater degree of severity than those who are not poor or disenfranchised. Our indignation when the former commit crimes has always seemed far greater to me than our indignation when the latter commit crimes. But certainly, punishment is a significant reason that we incarcerate people.
Incapacitation is a major reason we incarcerate criminals. At the very least, they are not out committing crimes. However, I seriously doubt that the crime rate goes down appreciably when we do so because there are always others to take their place. Still, there is certainly a viable argument to be made that at least these particular people are not out committing crimes.
Rehabilitation is a goal we seem to give lip service to, but the rate of recidivism is fairly high, I believe. It seems difficult to me to make an argument that something is a major goal if we seldom achieve it and make few if any adjustments to do so.
The idea that the incarceration of criminals discourages others from criminal behavior sounds quite reasonable, but the fact is that it is only the certainly of consequences that actually creates this affect, and there is little consistency or certainly in criminal sentencing. There is considerable research on this issue.