yawning began with the caveman. yawning makes you tired, also yawning is contageous, the idea being that when one of the tribe yawned the others followed. this regualated the tribes sleep pattern so they slept at the same time, and were awake at the same time in order to hunt in packs and survive.
the same is probably true of dogs, where once upon a time they were wild animals that needed to hunt in packs also