If students keep misbehaving over and over the consequence will just get worse than detention and you might even get either suspended or expelled which i am sure students do not want so i am sure there is no proof that students will keep misbehaving knowing that there are worse consequences than detentions!
Detention definitely has a purpose in schools. It shows student that if they behave badly, there is consequence to their action. If children and teens do not know this, they will not have a good moral compass as adults, leading them to believe that they can do whatever they want without having to worry about consequence.
Some students who are given detention learn not to do anything that would land them there again because to be quite honest it's very boring. Instead of after school detention though I would do Saturday school. That's what our highschool did when I went there and you had to either read, draw, or do homework for four excruciating hours. No phones and NO talking. It sucked and I never wanted to go again so it really does teach you not to do anything that would land you there again. But then for other students they could care less, just as long as they are expelled or suspended
Although many people argue that it will help them to learn from their mistakes or that they will be doing work in detention, most of the time that is actually not the case. The students just become angry at their teachers and misbehave again and again to try and annoy them. As well as this even if the students are doing proper work in detention it won't be to the best of their ability and they won't be learning anything.