The quick answer is, of course, you can legally end a marriage when a spouse is mentally ill. But the real question is may I end this marriage—i.e. can I give myself permission, ethically, morally to do so.
This question raises several issues. The most important one may be the definition of mental illness. It is very normal for divorce to elicit strong feelings, often negative ones—and for these feelings to change hour by hour, from sadness to anger to guilt or shame et al. It is often typical for divorcing partners to label each other as “bipolar” as they observe and are often the victim of these mercurial feelings. And while rapidly shifting feelings may be one of the symptoms of bipolar disorder, an accurate diagnosis includes several other important symptoms and can only be made by a mental health professional. The same is true for the broad category of personality disorders—it is tempting to label a spouse as “a narcissist” if, as is typical during a divorce, they engage in self-centered thinking or behaving. But again, a true personality disorder involves an enduring pattern of behavior, not provoked by a traumatic event, such as divorce. So be careful with “mental illness labels” and try to leave the diagnosis to the professionals.
But what about situations where there is a real diagnosis of mental illness, whether it be depression, psychoses or even schizophrenia? These are usually very serious conditions which greatly affect a persons ability to function in a relationship or on the job. Living with such a spouse can be very difficult, demanding and unsatisfying. One of the most important factors is the spouse’s commitment to start and follow through with appropriate treatment, which usually includes medication. Sometimes patients resist this—particularly with bipolar disorder, patients may balk at medication which moderates their “highs (manic states, which may be pleasurable) as well as the lows (depressive states). Without medication, the bipolar condition will not improve and may get worse over time and the same may be true for depression. Psychotropic drugs can greatly improve these conditions and even very serious disorders like schizophrenia may improve dramatically with appropriate medication, (which may also have negative side effects, such as weight gain). So if your spouse is willing to help himself with appropriate treatment. they and your relationship may improve perhaps, to the point that you are wanting to stay in the marriage. Another option is to consider joint therapy, where both of you participate in learning about and how to handle issues that mental illness presents in the marriage and how to improve the relationship for both of you.
So, of course, the decision is yours, whether or not to continue in a relationship with a partner who has a mental illness. But I think if you are supportive of your partner as they seek treatment, and educate yourself about their prognosis, you will make a decision that you can accept without suffering needless guilt or personal recrimination.