What is "insanity"? What is "mental illness"?
In his 1961 work "The Myth of Mental Illness", Thomas Szasz famously argued that what is commonly qualified as "mental illness" is merely a deviation from societal norms. Szasz argued that "mental illness" is a metaphor and not a genuine disease, that it is merely a way of dealing with problematic people in society.
“Psychiatry is conventionally defined as a medical specialty concerned with the diagnosis and treatment of mental diseases,” he wrote. “I submit that this definition, which is still widely accepted, places psychiatry in the company of alchemy and astrology and commits it to the category of pseudoscience. The reason for this is that there is no such thing as ‘mental illness.’”
Recent works like Paris Williams’s 2012 publication Rethinking Madness and Wouter Kusters’s 2014 Philosophy of Madness reiterate this notion. They regard "psychosis" not as a form of "mental illness", but as a variation from the norm that comes with both positive and negative symptoms. Others have made similar arguments with respect to Autism, ADHD, Dyslexia, etc.
In fact, psychosis, Autism, ADHD, Dyslexia and many other variations typically perceived as "defects" all commonly co-occur with high intelligence and creativity. Many (if not most) of the world's greatest scientists, artists and entrepreneurs are known to walk or have walked the thin line between "genius" and "madness".
So what is the role of "insanity" in society? Maybe those perceived are "insane" or "mentally ill" are just more extreme variations within normal human neurodiversity, who are far more sensitive to context / environment than the average human, but who often also can become capable of the extraordinary under the right circumstances.
To quote Bruce Feirstein :
The distance between insanity and genius is measured only by success.