If an animal has a vestigial structure, then the organism must have a long evolutionary history. The organ/structure was probably useful at one point, and over time, it became useless. Sometimes this is due to change of environment, change of diet etc. For example, humans used to make use of wisdom teeth because many years ago, dental hygiene wasn't really around and people's teeth would fall out. Wisdom teeth would develop 16-20 years later and people would be thankful that they then had new healthy teeth to chew!