Moral blameworthiness and randomness
Random punishment is counter to the principle of moral blameworthiness.
In Canadian law, this finds expression in:
- "not criminally responsible by reason of mental disorder" precludes a finding of guilt
- the prohibition on criminal punishment for things not proscribed by law enacted by the legislature (contempt of court is the only exception; see Criminal Code, s. 9)
- the prohibition on arbitrary deprivation of liberty
- the requirement that an act be voluntary — involuntary acts cannot make out the actus reus of an offence
- the requirement that a person have a certain mens rea commensurate with the offence
- that sentences are not to be grossly disproportionate to the moral blameworthiness of an offender
The harm principle
The principle of requiring moral blameworthiness does not go so far as to limit the criminal law to only dealing with things that are "really bad."
The "harm principle" advanced by John Stuart Mill is the principle that would restrict the criminal law power in the way you suggest in the final paragraph.
Recognition of the harm principle as a principle of fundamental justice would invite courts to decide whether something Parliament has deemed to be bad is "really bad" in the required sense.
The harm principle is rejected
However, the Supreme Court of Canada has rejected the idea that a "harm principle" is a principle of fundamental justice.
Instead, Parliament's criminal law power may be appropriately directed at anything with more than de minimis effects on public peace, order, security, health, or morality.
See generally R. v. Malmo‑Levine; R. v. Caine, [2003] 3 S.C.R. 571.