This is reduced a lot by early intervention, i.e. always provide housing and always provide free healthcare.
It is so much easier to handle being "slightly mentally ill" when you can trust 100% that you will always have housing, healthcare and enough money for food, clothes and other necessities.
If you can do 90%, then government can provide you with last 10% by paying rent automatically and having a social worker visit once a week. This fixes problems early compared to you becoming homeless.
There is a lot of steps between "fully functional middle class person" and "mental institution".