Sometimes insanity is the reason for the homicide. However, that's not enough to be a valid defense. The insane person has to be so insane that they weren't even aware that the murder was unjustified. In such cases, the person really should be hospitalized rather than thrown in prison. The environments are quite similar, but in the hospital the person gets treated for his underlying illness. In both cases the killer is locked up. Not infrequently, the criminally insane spend more time in a mental hospital than they would have spent in prison.
In most cases no one would willingly plea insanity except for in movies. Because they end up spending more time in the metal institutes then they would have in prison. Say that the murder victim raped or killed a mans wife, the grief could cause the man to temporarily go insane, and kill the guy who did it, without really taking into consideration that it's wrong.
I am not a doctor, but I'd say about 80% of the people who use the insanity plea are not insane. They were just mad and wanted something to give right now. I was on a jury and the guy tried to use insanity, but we didn't buy it.
Too much drugs taken and it became out of control... they use insanity instead they go to jail they go to a better cell which the mental hospital... imagine yourself in a prison where most criminals are there of course their not stupid they going to use an alternate reason which is an option to get insane so they went to mental hospital and in there they have nice bed and food and clean just like that .........