It might have happened but all the crime cases I have seen (mainly the mainstream doco's on the foxtel crime channel) being mentally ill doesn't excuse you of the behaviour, just in America if you are proven to be insane you won't cop the death penalty, at least that's how it was, not sure if it's still like that. They still inevitably get life, they just get life in a mental health facility.
You can be mad and not bad, just because you decide to be bad doesn't excuse you of the the behaviour, it's a choice made by the individual, not because they were suffering from some sort of mental health related issue.
Do you have any examples of where someone played the mental health card and got completely let off despite all evidence leading to the individual being guilty? I would be interested to see it.