1580s, "state of being insane," from Latin insanitatem (nominative insanitas) "unhealthfulness," noun of quality from insanus (see insane). Meaning "extreme folly" is from 1844.
insanity in·san·i·ty (ĭn-sān'ĭ-tē)
n.
Persistent mental disorder or derangement.
Unsoundness of mind sufficient in the judgment of a civil court to render a person unfit to maintain a contractual or other legal relationship or to warrant commitment to a mental health facility.
In most criminal jurisdictions, a degree of mental malfunctioning considered to be sufficient to relieve the accused of legal responsibility for the act committed.