My guess is that combatting gang crime was a major reason.
IMO what all these laws have in common is that they're designed to allow the police to legally ask questions to people (or straight up remove them) who look suspicious but haven't committed any crime. Why would anyone want to remove people who haven't done anything wrong is a more nuanced question that I'm not qualified to properly answer.
Your link refers to an article which is very American and very 2018. Lots of large font size headings about race and sexuality and gender. I don't think it's a productive take on how to manage the tension. Racially homogenous societies still need to decide how to handle people who try to sleep at train stations and yell at the commuters.
Places with less black-white racial animus were comfortable adopting animus for other minorities, or for the poor in general. Post-Civil-Rights, loitering laws (and a panoply of other practices ranging from swimming pools to mortgage approvals to cul-de-sacs) were exploited not to enslave, but principally to simply eject categories of people.
For a take on the origins of the Anglo cultural tradition of persecuting the poor in general, this goes a lot further back - https://www.youtube.com/watch?v=2ec9Al5ezYs