Use of 'they'
Since using they in English to refer to an unknown singular third person is incorrect, how does proper English use this sort of situation. In everyday English you would hear, "Who was at the door? Have they left yet?" or "I'm meeting my teacher tomorrow. Hopefully they are nice."
So how does this really work? It confuses me that colloquial English has taken the third person plural form of 'they' and formed into a substitute for an unknown gender of a pronoun.
So what's the background on this word and why is it used this way? Is it incorrect? How? What is correct?