“According to an eight-state study, the insanity defense is used in less than 1% of all court cases and, when used, has only a 26% success rate. Of those cases that were successful, 90% of the defendants had been previously diagnosed with mental illness.”
Mental illness has a much longer history of being (pointlessly) punished as 'evil'. A current one is the recognition that many people in prison may have untreated ADHD, which makes sense, just like a bunch of folk got kicked out of school for dyslexia in recent history (and then became successful artists or business leaders).
You could argue, people are now just faking dyslexia to get a pass on having to work hard at school, but if you can't demonstrate that to be a bigger problem than the genuine dyslexics being discarded as useless due to assumptions being made that they were stupid or troublemakers because of their condition, then it's a price well worth paying.
I’m puzzled by this question. Are you suggesting that all mental illness allows the one suffering to abdicate “past bad behavior”?