to punish sb as a warning to others not to do the same thing
make an example of sb
Definitions from the Oxford Advanced Learner's Dictionary, 9th edition