From the Middle Ages onward, people have been frightened or dismayed by the "crazy" behavior or speech of others. The idea of locking up mentally disordered people or placing them in asylums goes back hundreds of years and has often been mentioned in literature. In Shakespeare's play, Hamlet appeared to be mentally ill; Ophelia became mentally ill and killed herself.
Various theories have been put forth to account for mental disorders.  Religious ideas about mental illness have included demonic possession, to be cured by exorcism. Psychological ideas run a wide gamut.
Mental illness is generally considered to have dimensions of severity and impact, as well as legal implications. Some people are considered insane in some countries, and are excluded from society or given special consideration. A defendant may be judged not guilty by reason of temporary insanity. A severely mentally unwell individual may be psychotic or schizophrenic, while milder forms of mental illness are classified as a neurosis or syndrome (see Eating disorder or bulimia or anorexia).
Forms of Mental Disorder
Obsessional Compulsive Disorder
Types of mental health professionals
Mental illness and the law
The mental health community does not recognize or utilize the term "insane" or 'insanity", yet is called upon to give expert opinion as such in capital criminal cases where the life of a defendant is at stake. This is because the terms "insane" and "insanity", whilst written into the law in some countries, are not defined in or by the law. It is for mental health professionals to determine whether an individual is mentally unwell or not; the courts' role is to take the opinions of those professionals into account when deciding on an appropriate disposal for the defendant, which can include prison or detention in hospital under local mental health legislation.
In the UK, a defendant can be placed in a mental hospital (under the Mental Health Act 2007) if the opinions of mental health professionals agree that the person requires such care and treatment. The most dangerous of defendants who are mentally unwell can be made subject to Part IV of the MHA 2007, which includes provision for detention in hospital without limit of time.
Many courts apply the M'Naghten Rules as to whether the defendant was, at the time of the index offense, capable of knowing that what he was doing was wrong.
Liberal Senator Paul Wellstone was long in favor of spending money on mental illness coverage. A bill passed by the House of Representatives in March 2008, the Paul Wellstone Mental Health and Addiction Equity Act, would force insurers to cover mental illness at the same coverage level as physical ailments. The bill was sponsored in the House by Republican Jim Ramstad, a recovering alcoholic, and Ted Kennedy's son Patrick Kennedy of Rhode Island. A similar bill in the United States Senate was sponsored liberal Democrat Ted Kennedy, who has been addicted to painkillers; Pete Domenici of New Mexico; and Mike Enzi of Wyoming.  The Family Research Council has expressed its concern that this bill would force businesses to provide health care for mental "conditions" like necrophilia, pedophilia, cross-dressing, and gender identity confusion.
Even when a defendant is deemed sane, mental illness is sometimes used to justify a lesser sentence due to the defendant's diminished capacity which is said to render him less responsible for his crime. However, mental illness is also sometimes used to justify a harsher sentence if, for instance, a longer term of imprisonment is deemed necessary to protect the public from a defendant whose mental illness makes him more likely to commit crimes. A defendant found incompetent to stand trial can sometimes be confined to a mental hospital until such time as his competency is restored.
Mental illness and the brain
Scientists who adhere to a purely physical model of mental health regard mental illness as disorders of the brain. 
- "The English-speaking world has not always used medical language to describe the behavior we now label as symptomatic of mental illness or mental disorder. Descriptions were sometimes framed in quite different terms, such as possession. What we now call mental illness was not always treated as a medical problem." Stanford Encyclopedia of Philosophy, Christian Perring
- House approval is historic moment for Wellstone's addiction and treatment crusade
- Family Research Council: March 6, 2008 Update
- "Mental health disorders ... such as depression, bipolar disorder, schizophrenia and even borderline personality disorder are medical disorders of the brain." Mental Health Today