Deterrence, which includes specific deterrence (punishment of the offender) and general deterrence (example to others).
Retribution
Incapacitation of dangerous offenders
Rehabilitation of offenders
Restoration of victims (or the community)
Attainment of uniformity in sentencing .
In some societies, there is also a religious aspect to punishment.
What are the types of criminal law?
There are four main types of criminal law:

Common Law – Criminal laws passed by legislatures , as opposed to those created at the appellate level by judges . In this context, common law means a body of case law predating the United States Constitution and statutory laws which prosecutors, defense attorneys, and trial judges draw upon in determining how a defendant should be sentenced and what criminal laws apply.
Statutory Law – Criminal laws passed by legislatures . Only those statutes that specifically define crimes and set out the punishment for committing them are considered to be “criminal law”. Most court systems have hierarchies of common law which are cited as binding precedents , but there are several issues, such as the constitutionality of a law, that appellate courts generally consider to be questions of “law” which they are empowered to decide regardless of what previous cases there may be on point. Thus, every crime has at least one codified version in a statute .
Regulatory Law – Criminal laws passed by legislatures , as opposed to those created at the appellate level by judges . Only those statutes that specifically define crimes and set out the punishment for committing them are considered to be “criminal law”. Most court systems have hierarchies of common law which are cited as binding precedents , but there are several issues, such as the constitutionality of a law, that appellate courts generally consider to be questions of “law” which they are empowered to decide regardless of what previous cases there may be on point. Thus, every crime has at least one codified version in a statute .
Administrative Law – Criminal laws passed by legislatures , as opposed to those created at the appellate level by judges . Only those statutes that specifically define crimes and set out the punishment for committing them are considered to be “criminal law”. Most court systems have hierarchies of common law which are cited as binding precedents , but there are several issues, such as the constitutionality of a law, that appellate courts generally consider to be questions of “law” which they are empowered to decide regardless of what previous cases there may be on point. Thus, every crime has at least one codified version in a statute .