The law judges the crime, not the man.
There is a reason that the defensive plea of insanity is widely frowned upon by juries: justice is more about punishments fitting crimes than it is about making excuses for the criminal. If one person deliberately and wantonly kills another, should it really matter whether or not the murderer is "sane"?
Some modern sociological movements have tried to create a focus on the rehabilitational powers of criminal punishment. Justice, in their books, is more about 'reforming' criminals than it is about punishing wrong-doing. And there is some sense to the argument that it is in the best interests of the State to reform when possible.
But the argument taken on its whole is morally vacuous and devoid of practicality. Recidivism rates being what they are, the 'reform' focused movements are apparently attempting to save the entire herd from culling when many of that herd are rather patently unworthy of such protection.
What is the value of being a society that restores the criminal and ignores the victim? What is the value of punishing law-abiding citizens by subjecting them to the continued presence of repeat offenders? What is the value of sending a convicted murderer to a mental-institution?
The insanity plea arises from the same sort of logic that would turn the penal system into a mildly-unpleasant adult version of reform school. At the core of both is the belief that humans are basically good; likewise, both center upon the assumption that the circumstances of a person's life (impoverished upbringing, lack of schooling, mental impairments, and so on) dictate that person's fate.
Justice was formerly blind. Unfortunately, she has been granted her sight and does not know what to do with it.