Society needs order so that its citizens can enjoy their lives.
To ensure this, society has made laws that define certain acts and behaviour that violate that order and avenge the violation through punishment of the behaviour. Note that a criminal case is always brought in the name of the people of the locality: for example: State of New South Wales versus John Doe.
This also points to one reason why we have criminal laws. When the law (and thus the order of society) is violated by an offender, society wants the violation to be avenged. Society wants the offender to be punished so that the victim of the crime is avenged. This is retributive justice: giving the offender a punishment that is commensurate to the crime he has committed.
Criminal laws also have a deterrent purpose. If all offenders are proven to have truly committed a crime and they are consistently punished, then those who may be planning to violate the law in a similar way will think twice. Punishing crimes will prevent more crimes from occurring; it will prevent more criminals committing crimes. It has the purpose of showing to one and all that crime does not pay.
Criminal laws also serve the purpose of restraint. By providing for imprisonment as punishment, those criminals who may inflict hurt and damage to other individuals or those who may breach the order and tranquility of society are restrained in prisons, away from the society whose laws they have violated. Criminals will not be able to influence others to emulate their behaviour.
Criminal laws also serve a rehabilitative purpose. Those offenders who have been found guilty of having committed crimes are not imprisoned merely to keep them away from society, they are also imprisoned so that they can be separated from people and activities that pull them toward criminality.
When criminals are sentenced, the criminal justice system ensures that they get the psychological, spiritual and educational assistance so that they can put their criminal past behind them and become productive members of society once more. This is also referred to as the corrective purpose of criminal laws.
Disclaimer : This article is just a summary of the subject matter being discussed and should not be regarded as a comprehensive legal advice for you to defend yourself alone. If you are charged with criminal offences, it is recommended that you seek legal assistance from criminal lawyers.