I happen to have a small bit of perspective on the situation. My mother grew up on the wrong side of the tracks and much of my extended family is still there. I spent part of my childhood in the environment, and there was a crack house across the street from my home for a small part of it. My cousin was in a gang. (This is in a major drug corridor in the southwest.)
There's a large difference between a community member as a judge and a cop who doesn't even live in the area and views those who do with contempt. This colors their judgement, and the punishment often has more to do with the perception of the "defendant" than the actual crime.
Is the justice system often worthless? Yes. Are the cops any better? Not really, and I'd find them much worse.
Fundamentally, the problem is that Johnny can't get a job because he can't do basic math or read. Jobs within their reach aren't enough to pay bills, and those who can get the jobs that pay the bills leave the community, sometimes even their own families. (Those who can are often expected to provide for those who can't, which gets really tiring.)
The role models are poor. Those who are raised in the inner city often speak with an accent that isn't accepted by those in business. And these things encourage those to get into markets that are less inhabited by convention --- grey markets and crime.
Which the police don't understand -- they just see a thug.
The solution is that the police should live in the neighborhood in which they're assigned, they should be from or previously lived in similar neighborhoods, and the judges that see cases should be similarly informed.