Despite the fact that many dog owners report that their dog's preferred sleeping position is between their legs, there's not a lot of research on the subject. Here's what do we do know: A dog that sleeps pressed against you is trying to bond with you. Aw! Just like human cuddling, your dog is showing you affection by pressing against you.
Your dog likes to be near you.
Many dogs also like to sleep curled up or on their side. It's likely that your legs are simply conducive to these positions. Your dog wants to be both comfortable and to be close to you, and sleeping between your legs is a good way to accomplish both. Plus, she loves you!
Small dogs may cuddle more.
This position is probably more common in small dogs, who can actually fit between a pair of human legs. If you have a large dog, they may prefer to sleep back to back with you, or "spooning" you. This behavior is likely for the same reasons that their smaller counterparts want to sleep between their owners' legs: comfort and affection.
Some dogs instinctively burrow.
Additionally, some dogs love being burrowed under blankets. It likely evokes feelings of being in a safe, comfortable den, which would be comforting for dogs based on their evolution as den animals. Sleeping between your legs is an excellent choice for dogs who love burrowing, because not only does it guarantee that they'll be under the blanket all night, it provides the added comfort of being snuggled against you.
If your dog sleeps between your legs, consider it a compliment. Your dog loves you and wants to show you affection — whether or not it's comfortable for you.