“Reagan” getting credit or blame for this is largley misleading. There were a number of drivers..
Deinstitutionalizations was an important goal of the Community Mental Health Act of 1963.
Subsequently, a series of federal court rulings in the 1970s which restricted involuntary commitment and required paying patients federal minimum wage for doing work in and for institutions (like the prisons, mental institutions were slave institutions – on top of their myriad other problems – in all but name) undercut both the pipeline and the financial underpinnings of the system of institutionalization.
I understand the history well enough to note that a wide swath of (also) expensive alternatives have not been tried yet, or the basically sane people mentioned above would be willing to undergo treatment that works.