Some conditions diagnosed as mental illnesses are metabolic disorders.
Most so-called mental illnesses are disorders of status. A natural result of social interactions rather than quirks of nature or mysterious diseases
For survival, all animals from single cell creatures to mammals are genetically coded to relate to their world and each other.
Humans like other higher social animals are hardwired to socialise. Emotions are one of the mechanisms that organise their communities. Activities like blaming, shaming, adoration and forgiveness regulate the status of each member.
States like depression, elation, confidence, guilt and anxiety stratify groups by recording each individual's estimation of themselves and fixing their position in a social order. These states act as a currency that is stored in the memories and habits of each member and records everyone's social wealth and roles.
If you are at the top of the tree you get most nuts and less of the stress anxiety and depression that fixes individuals at lower ranks. At the bottom you get less or no chance to procreate and less of everything else except trouble.
Low status locks stress, anxiety or depression into place. If the resulting physiological changes become extreme they can lead to emotional, physical or mental breakdown.
If someone slips over the edge and becomes erratic or incapacitated, families and societies scramble to recover them, or on the other hand demonize them and leave them crucified at the crossroads, to mark the boundaries of acceptable behaviour. Or both.
The mentally ill, like witches often serve as scapegoats on which to project badness. The role is often rotated around family members.
Everyone else can feel OK and sleep sounder.