To put it simply, a dog’s eyes may sleep with its eyes open because it acts as a form of defense mechanism. Although many of us have adopted dogs and made them out pets, they are still wild animals. This means that they have the natural ability to guard themselves against nature and the world. They have somehow developed this ability naturally, and it has become part of their body or being. In the past, way before we have made them our pets, dogs needed to be constantly alert to make sure that they survive. As they evolved, they were able to develop sleeping with their eyes open, which may be the reason why your dog has this ability as well.
To provide you with a more scientific explanation, this is because dogs have a third eyelid. Their third eyelid can be referred to as the nicitating membrane. Basically, this membrane helps keep, create and sustain the moisture in their eyes while they are sleeping. This keeps their ayes from drying out. Why do they have this membrane? Similar to the previous explanation, dogs have this membrane because of evolution. Unlike humans, dogs cannot rub their eyes when some type of foreign object suddenly gets into their eyes, and their nicitating membrane does the work and protects them against it.
Basically, this may be what you are seeing depending on the type of breed your dog is. There are some breeds that have a nicitating membrane that are much more visible compared to others. Not to worry though, because this eyelid should go back to its original position once your dog is awake. If your dog is a Labrador, Chihuahua, Beagle or Bulldog, then the reason for them sleeping with their eyes open is because these types have more prominent nicitating membrane compared to other breeds. You can also do your research about which other types of breeds have this.