Those who have nothing and have been precluded from having the basic skillsets that will provide them with a reasonable pathway to success are going to have to try to find some way to make their way in the world that will provide for them the semblance of a life that would bring them some degree of satisfaction and respect. The proximate reason for gangs has an awful lot to do with the salient fact that those who have very little or nothing, who are thus without a voice or power, and pretty much are treated as the refuse of society, have then few viable legitimate options to make something of themselves, of which, therefore the lure of being a member of a gang entices them to take what they consider to be that necessary risk for the hope of achieving some sort of respect and success within their milieu.
Indeed, whenever they are enclaves of poverty, of hopelessness, of despair, and of a police force which is seen primarily by those who live within these particular bleak zones as essentially an occupying force meant to keep them in their place, then those that live within those conditions are not in a good place to become good citizens, which is thus further exacerbated by the dysfunctional public schools that have failed to educate them, which therefore lends itself to those that have grown up without a semblance of hope that they will themselves ever amount to much of anything, without then the aid of some other forceful entity, such as a gang.
The thing about gangs is that in a forlorn society in which so many are exploited or taken advantage of, we find that those who do not subsequently make alliances of some meaningful sort are going to therefore be vulnerable to being hurt, for those who have nothing to protect them and nowhere to run, aren’t in a good place, whatsoever. Further to the point, those who have a low self-image, for they know that their future is bleak, are going to recognize that being a member of a gang, will thereby provide them with the opportunity to have not only the respect of their peers, through that membership, but further to the point, provide them with the ready means to accomplish something that will get them some degree of respect, along often with something tangible that demonstrates their self-worth.
Those who are not permitted the fair opportunity to be successful in the orthodox way so expected of a well-functioning society, because they do not have the necessary tools or opportunity to achieve that success, are going to gravitate to joining together with those who are like-minded and who therefore are willing to risk what little that they have in order to take what they believe should be theirs, by working the angles and underground markets that provide them with the possibility of success, so accomplished by the strength of their gang and ingenuity. That is to say, gangs are often seen as a calling for the weak and dispossessed, so that when they are joined together they will collectively have power, and with that power, assert themselves so as to get their share, one way or another.