Mentally ill individuals are known as a shoteh. People who are classified as such are exempt from all mitzvot obligations. (Chagiga 2b) However, determining whether a person is a shoteh must be done on a case-by-case basis. Please see Who is a Shoteh? and the sources below for more information.
In particular,
As a result of this characterization of the shoteh as one who lacks understanding, the shoteh receives a general exemption from all mitzvot. This exemption applies to both positive commandments as well as negative commandments. The gemara details particular examples of mitzvot from which the shoteh is exempted, including the reading of the megilla and pilgrimage to the Temple. Furthermore, the shoteh is exempt from participation in communal obligations such as zimun before Birkat Ha-mazon. (Source: http://www.vbm-torah.org/archive/halak60/05shoteh.doc)
If the individual is not classified as a shoteh, then according to R' Moshe Feinstein,
Persons with other disabilities such as mental retardation, learning disabilities, epilepsy, or other acute or chronic illness or conditions must fulfill all biblical and rabbinic rules and precepts to their fullest potential. (Source: http://www.daat.ac.il/daat/english/halacha/tendler_1.htm)
Either way,
It is inaccurate to say that the Torah’s laws do not apply to those who are exempt from mitzvot. For example, it is forbidden to feed non-kosher food to a child (Yevamot 114a), a cheresh or a shoteh (Chatam Sofer (I, 83)).
In addition,
Since people who are exempt from a mitzva receive reward for fulfilling it (Bava Kamma 87a), one might posit that there is intrinsic value in their performing mitzvot. However, this is unclear, as their actions lack the necessary level of cognitive intent (see Chulin 12b). (Source: http://eretzhemdah.org/newsletterArticle.asp?lang=en&pageid=48&cat=7&newsletter=106&article=337)
Finally,
While some may argue that the shoteh's exclusion from the obligation of mitzvot suggests an element of discrimination, we could conversely claim that this paradigm of halakha actually demonstrates sensitivity to the position of the shoteh. The functionally impaired shoteh is not burdened unnecessarily by obligations which would only serve either to add a further stress to an already challenged psychological state of mind, potentially exacerbating the clinical picture, or to impede recovery from a current disabling psychotic illness. (Source: http://www.vbm-torah.org/alei/8-8newrs_sen.rtf )