Why do dogs turn around three times before lying down?

Why do dogs turn around three times before lying down?