From a quick Google search, docking is done to prevent injury to the stallion in mating and is thought to increase the frequency/ desire for the stallion to mate. There are, of course, more humane ways of accomplishing this but that’s the historical justification for the practice