A bit of ancient history here:
In William Parkes book, Curtain-Drawer of the World (1612), we find this reference to the practice of raising flags to announce plays:
"Each play-house advanceth his flagge in the aire, whither quickly at the waving thereof are summoned whole troops of men, women, and children"
Flags were used by the Globe Theater to announce and proclaim the performance of a play. The modern equivalent is the theater marquee. Today theater marquees remain the same for as long as a particular play is performed. In the time of Shakespeare, plays changed or were postponed daily, and so the theater-going populace needed to be kept current about the latest showings. Think of the flags as the first theater advertisements.
Here are the colors of the flags and what they meant:
Black: The play was a Tragedy
White: The play was a Comedy or light-hearted in nature.
Red: The play was a History. (Red was chosen because history is often bloody :-)