It forces you outside, which boosts vitamin D (sunshine) and helps you see things from a fresh perspective. Being outside with your pet (if it is an outdoor animal) gives you both a little exercise and strengthens your companionship. When you combine movement and companionship, you enjoy a natural serotonin surge.
When you are out walking your pet, whether a dog, a horse, or another pet, it helps you to unplug and be in the present moment, just you and your pet.
The rhythm of walking with a dog, and many other pets, can feel meditative. It can help you put your worries aside and just enjoy the time together outside. Watching your pet enjoy the world adds joy to your own. The two of you are actually sharing something that both of you enjoy.
