He needed to teach them a lesson in a way they'd understand. When you grow up a little more and have kids yourself maybe you'll understand too. His heart before he died showed his innocence.
Is that what you think? Well let me inform you, that one of the greatest human beings in all of world history, the prophet Muhammad said "hang your whip where it can be seen by members of your household" ( see
https://shamela.ws/book/13174/19428#p1 and
https://sunnah.com/adab/50/25 ). Maybe you should broaden your mind before you assume. When you assume, you make an "ass" out of "u" and "me".