The answer is genetic and health habits.
Genetics act as a predisposing factor. Studies have shown that having some genes makes one susceptible to mental illness especially at older ages. An example is the DISC1 gene, which has been associated with schizophrenia.
Health habits that expose one to mental illness include poor nutrition, exposure to toxins such as lead and substance abuse.