A dog wags its tail as a way to communicate with humans and other animals. It can indicate various emotions such as happiness, excitement, or even nervousness. Dogs use their tails as a form of non-verbal communication to express their feelings and intentions.