The real answer, of course, is that Hogwarts is shaped after British public schools, and it inherited gender-based dorms just like it did the four-house system.
A possible justification/rationalisation is that there are drastically different dynamics between a sexual attraction that involves a vast majority of the population, and one that involves a minority: heterosexual affections are much more likely to be potentially returned, compared to homosexual ones. Hence, while the occasional homosexual affair will sprout up in an all-male/all-female dorm, a mixed teenage dormitory would be completely overrun with drama, awkwardness, and unpleasant sounds and smells.
I can think of a good reason for segregated dorms: In the MoRniverse at least, rape is something aristocratic boys can do casually with the full expectation of getting away with it. Not to mention panty raids and other assorted sexually-harrassing nonsense. Even in a society without medieval/Victorian mores, girls would still need a place of relative safety in which to sleep, shower, dress, etc..
ETA: There is now a third thread, so send new comments there.
Since the first thread has exceeded 500 comments, it seems time for a new one, with Eliezer's just-posted Chapter 33 & 34 to kick things off.
From previous post: