It could've been easily prevented by actually arresting someone that committed abject murder, but the city and the police chose to instead defend a man who has killed multiple people in the past and got away with it scott-free. So when people feel like justice no longer exists, there should be no surprise that they get angry.
It doesn't help that the police also employ agent provocateurs whom help incite riots and looting so that they can use more violent tactics with glee.
To put it with MLK: A riot is the voice of the unheard.
The systemic issues of the Black (and other foreigner) community across the Western societies, especially with police and laws specifically designed to target them (e.g. almost all drug legislation), have been ignored for way too long. I'm no friend of rioting myself but I will not judge upon those who have deemed it necessary to be finally heard.