The Criminal Justice Act 2003 sets out five aims of sentencing:
the punishment of offenders (retribution)
crime reduction, including through deterrence
rehabilitation of offenders
protection of the public (incapacitation)
Any or all of these aims may be relevant in a given case and it is for the judge or magistrate to decide how they apply.