Birds are known to have evolved from the reptilian dinosaurs and feathers are highly modified dinosaur scales. The origin of mammalian hair in deep time is less clear because hard scales, bones and feathers preserve better than other types of tissue.
Fossil imprints of hair are found in Middle Jurassic species, such as the beaver-like Castorocauda, about 220 million years ago. And a mammalian ancestor with fossilised fur, the rat-like Spinolestes, which had a mohawk of bristles, is known from the Cretaceous period, 125 million years ago.
Such fossils are rare.
But scientists have found food residues that contain hair-like structures inside fossilised faeces from the Permian period, around 260 million years ago.
We can take a look, however, into mammal ancestor evolution to get a better understanding of fur and hair evolution.
We know the mammalian and the reptilian lineages separated from each other more than 300 million years ago. The first mammalian ancestors still looked very much like reptiles.
But they had a different diet. They hunted on large prey with their fangs, whereas reptiles originally fed on small spiders, millipedes or insects.
Constant temperature is an essential for stamina, in mammals, which you need for hunting. This can be accomplished, among other things, by developing fur.