Anyone that has watched enough anime outside the shounen and fantasy genres notices that every other show seems take place in a high school. They feature characters that are high school students, or are based on a certain kind of after school clubin a high school.While fanservice potential no doubt contributes to the reason this is such a prolific setting, I believe the perfusionthink it stems from cultural norms.
There's a Japanese proverb, "the nail that sticks out gets hammered down", which I'm sure feels right at home in the rigid, protocol-filled Japanese society. Japanese people are expected to conform to societal expectations and behavior by the time they enter the professional world. While they are in the education system learning about science, history, and the 50 billion kanji they need to know to be literate, they still have some freedom to act like fun-loving teenagers instead of like robots responsible, conforming adults. Due to the less strict environment and the fact that schools are a powerhouse of social interaction, characters are much more likely to express their personalities. No doubt this is where many of the archetypes that come up in every main character's class come from.
Another thing that may come as a surprise to us baka gaijin is that high school is much more important than high school in the West. It is actually more important than college, which is more like a victory lap where they can dick around before actually beginning a career (though their college parties are comparatively lame a hell). As such, Japanese students work their asses off to get into great high schools and bust their nuts doing schoolwork thereafter. High school for them is much like college for us in that people will move out of their parents' houses and live by themselves to go to a better high school (e.g. Hidamari Sketch, Toradora!, Sakuasou no Pet na Kanojo, etc.). If you've ever asked yourself why lots of characters' parents are mysteriously absent, there you go (in addition to really convenient working abroad situations).
The higher stakes and pressure of Japanese high schools seem to drive their student to develop a relatively higher level of responsibility than their Western counterparts. This maturity can manifest as having many more options of how to spend their time than middle schoolers or professionals. Add after-school clubs and other social events that are born from school life as well as the various types of personalities and behaviors that classmates can exhibit and it should become abundantly clear how incredibly versatile this setting can be in terms of the scenes that can play out as well as the types of story you can tell.
What is interesting is that anime based on this realistic, common experience are not limited to the slice of life or comedy genres. Fantastic and supernatural shows like The Melancholy of Haruhi Suzumiya, Angel Beats, and Bakemonogatari also stem from this otherwise pragmatic stage, perhaps even because it is realistic and therefore more accessible than the new worlds of Tengen Toppa Gurren Lagann or Shinsekai Yori.
In developed countries, high school tends to be a rather universal experience, with some saying that those years are the best of our lives. So does the high school scene keep cropping up because of a nostalgia on the parts of the creator and the audience? Is it the narrative power of secondary education? Is it the anime industry trying to saturate the world with zettai ryouiki? If nothing else, one thing is for certain -- few other settings can
outclass high school.