The justification is usually made with respect to "urban environments", "public housing", and "poor people", eliding over the racial implications.
Also, street gangs like the Crips, Bloods, and Vice Lords were turning streets into war zones as they struggled to gain control over the crack trade. Nowadays, black gangs control the PCP market, and sentences for that are harsher than something like Ketamine, another dissociative anaesthetic. The media are also all too happy to put a naked psycho running around, punching passing cars, on their evening news.
The legislators can try to justify it all they like, but all of us watching can clearly see that whether it is intentional or not, causative or merely correlative, the mandatory sentencing laws are putting more black people into prison, and keeping them there longer. "Three strikes" laws are having a similar effect.
There was public hysteria over crack, and Congressional Democrats wanted to show they were "tough on crime."
This should help disabuse you of such thinking. The Racist War on Drugs: https://www.youtube.com/watch?v=wONAqaxgIoo