The latest episode of The Philosophers Zone is all about psychopaths. It brings a great perspective to the issue of mental illness and the law, specifically around psychopaths and their awareness, or lack thereof, of what is morally right and wrong.
They hinted at the purpose of punishment and how that changes when the guilty party is mentally ill. The notion that a person should be punished disappears when the capacity for moral awareness is absent. However, that doesn't mean that the culprit shouldn't be incarcerated. In that case, the incarceration is for the protection of society and to, for want of a better word, force treatment upon the perpetrator.
Generally speaking, I'm ok with this. I think it still allows a legal system to identify who committed the illegal act, but also the liberty to apply a different kind of sentence for the mentally ill than for others.