School represents the last time people could have fun without having any responsibility other than studying. Many Japanese didn't have a nice time in high school due the pressure of exams and getting into university, then there's bullying, heartbreaks and so on. An idealized high school life might be entertaining to watch, both for adults who slave away every day and for teenagers, after all there a lot of different genre you can set in a school, it's a very versatile setting.
Personally, I wish there were more anime and manga set during university years because that's actually when Japanese people have fun: they can finally drink, smoke, drive and have all kind without too much pressure (no one studies in university in Japan, unless they study medicine). I'd even appreciate more work settings if they weren't so boring and repetitive.