Moulting is a feature of mammalian physiology that will be familiar to pet owners worldwide. While it's not present in all mammals, it is very widespread despite the fact that, when you think about it, it's obviously costly to the animal in question. Why shed and replace a large amount of hair in a short time when you could replace it bit by bit as humans do?
The fact that so many mammals, of widely different kinds, moult to at least some extent shows that it must be an evolutionary ancient phenomenon. In fact, it turns out that animals have probably been moulting since before they even had hair. We can tell this because it's not unique to mammals. For instance, birds moult their feathers, and the process is similar to hair moulting in mammals. More significantly, perhaps, moulting has the same underlying mechanisms as reptiles periodically shedding their skin and can be tied back to sloughing in fish and amphibians as well.