If anything, someone with a mental illness seems more dangerous to the public than a sane murderer who could have just really hated his wife (although obviously I am not saying that murdering her is ok in that instance).
Well, ordinarily, when a person is declared mentally unfit to be prosecuted they get sectioned under the mental health act. If they are deemed to pose a danger to themselves or the public they are kept in a secure hospital somewhere. Which is in effect the same as putting them in jail, except they will receive treatment for their illness.
Well, seeing as mental illness is a fantasy of psychiatrists and their followers, it’s a fictitious defense. But it sounds like a moral hazard here; if people have problems like imagining their spouse cheating, excusing them not taking steps to resolve this peacefully (counseling) tells others that they can just ignore their imaginations and be let off if they hurt someone.