Pets wag their tails as a form of communication. It is a way for them to express their emotions, such as happiness, excitement, or even nervousness. It is a behavior that is often associated with positive feelings and is a way for pets to interact and communicate with their owners and other animals.