Robert was king and he was doing good compared to some other monarchs. Varys had never met Dany, and didn't know what she could do, so of course he preferred Robert over Dany. After Robert dies, and after a few seasons of looking for someone else to replace Joffrey, he decided that Dany would do fine, as he saw her protentional after she conquered the cities. And when Varys found that she was mad, he looked for a better ruler or heir, and found Jon Snow. What was he supposed to do, just let Joffrey keep ruling?