I'm glad they got caught. That will 'teach them a lesson'! [=they will learn that they should not do that again]
We 'learned our lesson' the hard way. [=we learned from an unpleasant experience]
They studied the 'lessons' [='teachings'] of the great philosophers.
(..) He tortures toys, just for fun! Well, then we've got to do something. What are you doing? Get down from there! -I'm gonna teach that boy a lesson. -Yeah, sure. You go ahead. Melt him with your scary laser. Be careful with that! It's extremely dangerous. He's lighting it! (..)1995 Toy Story