The phrase can refer to both good and bad outcomes based on one's actions or behavior. After cheating in the game, he was disqualified and truly got what he deserved.
Pro Tip 2/3
Moral Judgment
It's often used to express a moral judgment about fairness or justice being served. The community felt he got what he deserved after he returned all the stolen items.
Pro Tip 3/3
Emotional Weight
This phrase can carry a strong emotional charge, especially in sensitive situations. Once the truth came out, everyone said she got what she deserved, but I felt sorry for her.