Most dogs tend to curl up when they are sleeping because it helps them conserve body heat and protect their vital organs. This behavior is instinctual and is seen in many species of animals, not just dogs.
Most dogs tend to curl up when sleeping to protect themselves. By curling up, they retain body heat and conserve energy while sleeping. It also allows them to stay alert and easily spring into action if necessary.