What a lot of people seem to be missing...
Some crimes are based on the criminal making an assessment of risks and rewards: "I can rob that liquor store; I'll net $1,200 cash, and the chances of getting caught and punished are slim." For those people, punishment, a.k.a., throwing the book at them, is a sensible deterrent.
There are other people who act badly because they are, to borrow a technical term from psychiatry, bat-**** crazy. Punishing those people doesn't accomplish much. The person who tries to open the overwing exit in flight because the voices are commanding him to do so, is not going to be deterred in the slightest by the notion that the last guy who tried that got sent to jail for 5 years. Nor is sending this guy to jail for five years going to deter the next bat-**** crazy person from acting out.
Yes, he definitely needs to have his liberty restricted so as to reduce the risk he poses to others and to himself, but no, punishing him doesn't make a whit of difference.