It was used in the 20s-70s for students (usually male) who had disrupted class. The idea was that they had to wait in the hall (where everyone would see them) holding buckets of water (quite heavy). If you put them down, everyone would see that you were weak and the teacher would give you crap.
It doesn't happen any more. Just sending a child out of the classroom is illegal under Japanese education law. Corporal punishment of any sort is strictly outlawed.
Now it's something used in fetish erotic stories and erogames because guys apparently like seeing cute little girls "suffering" and the concept of "punishment". I assure you, there aren't any classroom orgies or spankings either.