To me it sounds like you are dealing with the aftermath of severe trauma. Yes, you certainly were institutionalized. I won't pry about the reasons, but I can suggest some reading for you, and encourage trauma-focused therapy with a highly-rated psychotherapist. I'm currently using the app Talkspace for my trauma-focused therapy and it works great for me personally, so look into it if in-person therapy isn't your thing.
Here are some books that could help you come to grips with what has happened to you:
Mad Pride: a celebration of mad culture.
https://www.amazon.com/dp/095257442X/ref=cm_sw_r_cp_awdb_-yPCyb5HXHV3J
The Center Cannot Hold by Elyn Saks
https://www.amazon.com/dp/1401309445/ref=cm_sw_r_cp_awdb_RBPCybC9C82ED
Recovery From Severe Mental Illnesses: Research Evidence and Implications for Practice.
https://cpr.bu.edu/store/books/recovery-from-severe-mental-illnesses (Volumes 1 & 2 are both on sale and volume 2 specifically is about interventions with strong evidence backing their efficacy in recovery rates. Many are non-psychiatric and community-based rather than institution-based)
Foucault is essential reading for understanding institutionalization at its core, the "othering" of those deemed mad by society's dominant forces, and the essence of the Mad Pride movement (some of which I find valuable, while other aspects I toss aside as anti-science garbage. But as a historical and social movement it is significant and extremely empowering for those of us who have suffered from psychiatric abuse). History of Madness/Madness and Civilization is probably most directly related, but Observe and Punish is probably a more fleshed-out treatment of the same idea, and potentially more relevant to you. A google search should provide plenty of PDFs.
As far as value to society, your line of thinking is exactly what the dominant group would have you think. That if you're not fully participating in and contributing to capitalism then in society's view you have no value. If you're deemed "deviant", you might as well be invisible. Personally, that doesn't make me that unhappy anymore. It makes me want to fight back and live on my own terms. Why should we have to conform? Why do we have to be valuable to a sick society in order to be valuable to ourselves? We didn't ask for any of this. We didn't ask to be born into this bullshit.
Some other reading you may find comforting is The Myth of Sisyphus by Camus. Again, PDFs abound. You may find that it settles the question of suicide once and for all. It did for me. It changed the entire definition of "meaning of life" for me when I had my first psychotic break and subsequent suicide attempts. I reread it recently and it resonates still. But I have a really soft spot for Camus...
i would really suggest looking into trauma recovery. I am quite sure that you would be diagnosed with complex post-traumatic stress disorder upon evaluation. No one goes through that amount of institutionalization without scars. Especially as a juvenile.
Let me know if you have questions. You have really suffered. It does get better, I promise, but it will take some effort on your part. But it is definitely possible to make the bad days a bit better a fewer and farther apart. Then good days become more frequent.
Hang in there.