Because Robert isn’t an unkind man and would want his bastard child taken care of and Varys would be the man to do that discretely, because Varys doesn’t cause unnecessary harm to children (while being bang alongside the idea of necessary harm to children), and because Varys would want a bastard of Robert’s on hand to de-legitimize Joffrey/Tommen when the time was right.