I hope the answer is more than "it's just a random number between x and y" because that would make this the shortest research in the history of this board. Is there anything that is known to factor into the number, such as the species of Pokemon you hatch, the distance required to walk with the egg, the age of the egg, the incubator type, the time of the day, the day of the week, the number of the same candies you already have etc.?
It would honestly surprise me to hear there was absolutely no way to do anything about it, because to get 35 candies instead of just 5 converts up to 150 kilometres that I no longer have to walk with the same buddy. Leaving something that huge for an RNG to decide is simply too gross, weird and unbecoming.