Interesting BBC article on some research into yawning:
BBC NEWS | Health | Yawning may keep us ‘on the ball’
Apparently yawning cools down the brain - to help keep us awake and it may be infectious because it is a survival instinct to yawn when you see others yawning - i.e. staying awake and alert.