High intelligence and insanity do not necessarily go together. One reason there could be the perception that high intelligence and insanity go together more than they really do could be explained by the fact that many of the people most famous for extraordinary intellect accompanied by mental health problems are people who had high ability in one area while actually lacking mental development in other areas, leading to their being very accomplished in their field of expertise but lacking in coping skills and other abilities that make a person generally well adjusted.
Another point is that mathematical and scientific "genius" are often the result of a person's having those skills in extremely high degrees without having equal or sufficient development of the skills needed to be a well adjusted person who can cope well with stress. Whether the person who lacks "person" skills (understanding of self and others)became interested in math or science because those subjects allowed him to focus intently on them rather than require more interpersonal interaction, or whether his brain is actually so well developed in the skills associated with math and science he just gravitates toward those subjects is a question. Either way, at least when it comes to extraordinary math and science accomplishment the person most likely to be known for either of those may also be more likely to have difficulties when it comes to "just being a person" and knowing the most well adjusted ways of dealing with stress and pressures. In other words, high intellectual ability in the singular subjects of math or science without being balance by similarly high ability in other mental skills could account not just for the math genius with leanings toward mental illness but toward the "run-of-the-mill math person" who lacks what is called "common sense" but what is really a type of intelligence associated with a different part of the brain.
There is, however, high intelligence accompanied by excellent mental and emotional health. The intelligent person who is not focused on a single subject, such as math, though, and who instead has interest in many subjects (which is actually part of the definition of "gifted") can be less inclined to devote the time and energy needed to achieve extraordinary accomplishment because of his/her multiple interests. Also, though, the person with "well rounded" high intelligence is often more likely to be overlooked by the schools as a result of the fact that this type of student may high his/her intelligence, may underachieve for any number of reasons, and may even see "being the best" in school as less important than a math-driven counterpart may.
Since science knows that girls tend to lean in the direction of developing certain mental processing skills while boys tend to lean in the other direction, and since the skill development toward which girls lean more includes the skills required to essentially know how to be a well adjusted person, the fact that males have historically been the primary contributors to the world's major accomplishments could explain why those who are known for brilliant accomplishment in history often lacked those "knowing how to be a well adjusted person" skills. This is not to say that boys cannot be nurtured into a more well balanced set of intellectual abilities. It is to say that there is the chance that at least in those instances of extraordinary math-related or science-related accomplishments in history the likelihood that those who achieved fame for their extraordinary accomplishments may have lacked the balance of skills needed to be completely mentally well adjusted and healthy.
It is said that the role of women in teaching their children is the likely reason women lean more toward skills involved in "building well-adjustedness" or "living" or "common sense", but skills women are known to lean toward also include memory, reasoning, logic, and analytical skills. My aim is not to underestimate the skills boys naturally lean toward developing, but my point is that spatial skills do little to help a person know how to deal with stresses, be well adjusted, and have the social skills that humans do tend to need.
As the mother of one adopted son, one biological son, and one biological daughter, I have seen for myself that it is entirely possible - with paying the right attention - to nurture children in a way that encourages development of all skills; and although I could be incorrect about this, I am under the impression that boys require more active nurturing of the skills they are less likely to develop as well with it while girls require active nurturing on those skills they are less likely to develop as well without that nurturing. I realize that my own family provides only anecdotal evidence, but there is at least a certain amount to be observed in adopted and biological children of different genders, nurtured the same way.
Schools, naturally and rightfully, value academic achievement. Schools often are not capable of knowing which students have extraordinary potential but underachieve (sometimes better-than-average-but-not-great grades can be underachievement without looking like it, but sometimes underachievement is related to a student who gets terrible grades and has extraordinary potential). As a result, there is a naturally occurring screening process in schools that causes students with "specialized" skills (particularly in math and science, which are often considered subjects requiring "more intelligence" than verbal-skills subjects) and with the inclination toward intense focus or just the natural ability to excel rise to the top, become known as the "most intelligent" students, but are also often seen as "odd" when it comes to their personalities in general.
One of the definitions of a "gifted child" is his or her interest in a lot of subjects, and there are children who, when tested, will show superior ability in all areas of mental processing. Regardless of any natural leaning toward development of skills associated with either gender, anyone who has tested people's IQ's knows that people who test high on all areas do exist, and that includes people who test extremely high. One problem is that the person who is very well balanced and mentally healthy AND who has high ability is often the person who places family or other life factors first rather than devoting the time and energy needed to pursue career interests to the degree that the more singularly focused individual will. This, of course, means that the more narrowly focused individual is more likely to acocmplish great things but is also more likely to be prone to mental health issues involving lack of balance.
While there was a time when people (for example, the Founding Fathers of the United States) with high verbal and reasoning abilities were seen as very intelligent, with the arrival of the high-tech age and the reality that high-tech careers often meant higher earning potential, schools in recent decades have often completely failed to realize that there are intellectual skills related to intelligence that are separate from math/science-related skills. Teachers, students, and others have come to think of math and science ability as the only signs of intelligence. Attention has been paid to how to get girls to catch up with boys; and the irony of an age where Feminism bloomed is that the skills that often come more naturally to girls than boys are the very skills people stopped paying attention to somewhere between the signing of Declaration of Independence and the first computer system.
Because I have read that there has been some connection drawn between high intelligence and insanity, I can't say that there is never a connection to at least some types of high intelligence. I do know, though, that there is vast ignorance about what intelligence is and what it looks like and where it comes from. I also know that high intelligence, when it comes in balance and not in specific areas, can be associated with superior mental and emotional health every bit as, if not more than, average and lower intelligence are.