As a setting itself, the greatest advantage that school offers is the expected (forced?) social interaction with a sizable cohort of others of close age. But as this alone doesn't seem to explain its popularity, I think it has less to do with school itself, but more with the age bracket. It would be part of the larger phenomenon of children and teens being popular choices as main characters. The characters are at an age where they go to school, and so therefore school is part of the story. And I don't think children being popular as main characters is exclusive to Japanese culture.
In erotic works you'd expect the settings to be effected by to both the main character and the target of attraction. VNs and manga relying on fanservice may therefore exhibit even greater frequency of the school setting, as the target of attraction would often go to school as well.
Hm... maybe someone should do some statistical analyses...