Justice-Based Schadenfreude is the type of joy a person experiences when someone that the observer views as immoral or "bad" is shamed or otherwise harmed. It is the pleasure associated with seeing a "bad" person being harmed or receiving karmic retribution. For example, many people would feel happy upon seeing a politician who recently won an election, fall from grace and get indicted for campaign finance violations.
Schadenfreude is experienced here because it makes people feel that an fairness has been restored for a previously un-punished wrong.