It may, for example, be a way of signalling to others that it's important to remain alert and stay awake in a certain situation. Another theory is that our early ancestors used it as part of their social behaviour, and as a way to help build a bond with the rest of the group.