What is a tail for?

A Tail is used for certain animals to help them with their life.For example,a cow uses its tail to swat flies,and dogs wag their tails when their happy.