Absolutely it should. Our justice system is premised on the idea that we not only punish behavior but that we punish culpability.
A person who knowingly, deliberately and intentionally commits a crime should be treated differently than a person who commits a offense but without the same knowingly, delieberately and intentional mindset. That is not to say that the behavior cannot be punished, it is a question of culpability.
We treat children differently because they are not expected to have the same capacity to form intent and the same maturity to rationally think about their conduct. The same is true of the mentally retarded. That same belief extends to the criminally insane and the mentally ill.