The teacher is hoping the rest of the class will socially punish the disrupting student in some way. They are doing this because teacher have no means of punishing students other than this and scolding.
I would like to once again remind the youth that collective punishment is a crime against humanity and you should contact the un human rights office and get your teacher sent to the hague.
If I could say something to my 13 year old self who hated being 13 too, it would be "it gets better, but it also gets so much weirder and complicated. Also you have ADHD and autism maybe, get that checked"