Don't blame Reagan. He gutted most of The Mental Health Systems Act of 1980 that Carter signed in the last months of his presidency - with the intent of pushing health back to the States (where it belongs). Deinstitutionalization preceded that by two and half decades.
From Wikipedia:
Deinstitutionalization began in 1955 with the widespread introduction of... Thorazine... and received a major impetus 10 years later with the enactment of federal Medicaid and Medicare. Specifically, a provision of Medicaid largely prohibited reimbursement to states for mental illness treatment in facilities that had more than sixteen beds. This clause incentivized states to close their larger mental hospitals and offer treatment in a community out-patient setting, which was 50% reimbursable under Medicaid.
In 1955, there were 558,239 severely mentally ill patients in the nation's public psychiatric hospitals. By 1965, the number had declined to approximately 500,000... approximately 100,000 by the early 1980's... reaching 71,619 in 1994 and 62,532 by 2014.
The increase in homelessness was seen as related to deinstitutionalization. Studies from the late 1980s indicated that one-third to one-half of homeless people had severe psychiatric disorders, often co-occurring with substance abuse.
When laws were enacted requiring communities to take more responsibility for mental health care, necessary funding was often absent, and jail became the default option, being cheaper than psychiatric care. In 1960, 55,362 individuals with serious mental illness were incarcerated in state and federal prisons. By 2014, that number was 392,037.