The best current thoughts (guesses) are that chestnuts are a remnant of the toes prehistoric horses had. They think the ergot is one toe, the chestnut is another and the other three fused to become the hoof.
Horses are known to have chestnuts due to constant or repeated contact and friction on the bodies of horses. The chestnuts are known to grow over time, hence changing in size and shape. This leads to horse grooms to peel off or trim the outer layer.