The real answer is unknown. MSN Encarta explains the current leading theory:
"[Professor Robert] Provine's theory is that group yawning is a leftover response from the time we were tribal creatures. ... Provine believes that yawning together helped synchronize our tribes. When we were tired, we yawned, and everyone got the idea that it was time to go to bed."
(Why is yawning contagious?)