When something bad happens to a person and you're glad about it, you can say that the person "had it coming". It means something like "It's natural that this happened" or "It's good that this happened."
Why would you be glad about bad things happening to a person? For example, if the person:
- is mean
- is dishonest
- made bad decisions
- didn't obey your orders
You can say this about a person who's not listening:
A: He lost all of his money gambling.
B: He had it coming if you ask me.
You can also say it directly to someone, although it's certain to make them angry:
A: Jesse and his boys grabbed me and beat me up.
B: Yeah, well, honestly you had it coming. You shouldn't have messed with him.
You can also say "I had it coming" about yourself.