Short answer: Varys is making sure the powers in Kings Landing are divided and underprepared for the army they intend to put someone Varys and Illyrio
want to be king on the throne. He targeted Pycelle specifically because Pycelle was the one taking that threat seriously: mapping their army's movements and advocating swift action before Connington & co establish a strong foothold.
Is Varys acting for the good of the realm? We only have his word for it. Based on what his co-conspirator Illyrio tells Tyrion, it seems more likely that Varys and Illyrio are conniving to put a pliant person they can influence, control and predict on the throne. They see themselves as doing what is right - people are great at self-justification - and that might be true, but it can all be explained by ambition. They achieved all they can in Pentos, then the next level up is to become the power behind the absolute ruler of an entire continent.
There's also a popular and convincing fan theory that there might be another level to why Varys and Illyrio want this particular person on the throne. There's a detailed account of it in the top answer to this question here. Warning: if this theory is true, it might be a massive spoiler for a major plot development in a future book. (Second warning: it's really long!
:-) Very thorough and well sourced)
As for "why did he kill Pycelle?", earlier in the epilogue, Pycelle:
- comes across as the person on the small council who takes the threat posed by Connington's pro-Aegon (therefore pro-Varys) adventures most seriously
- shows a detailed map of Connington's incursions. He is clearly following news of them closely and knows more than anyone about their movements
- suggests paying the Golden Company to betray "Lord Connington and the pretender" (to which, ironically, Kevan suggests seeking a loan from "the magisters of Pentos", i.e. Illyrio and his peers and rivals)
- mentions that he's in conversation with Oldtown about news of Daenyrs, and encourages the rumours here to be taken seriously
Everyone else is too pre-occupied with their own petty political agendas to take serious action - which is what Varys wants. Kevan risked disrupting Varys's "divide and rule" strategy, and Pycelle risked prompting swift action that could have snuffed out the foothold Connington was building up.
Pycelle's comments all touch on genuine weaknesses in the Connington conspiracy, which is reliant on sellswords and vulnerable while its landing parties try to gain a foothold.
Something as outrageous and un-Varys-like as blatant murder has the added bonus of stoking Cersei's waning paranoia, fuelling useful non-Connington-related intrigue and distraction. Especially since he used Tyrion's signature weapon.
An additional possible factor (and maybe the answer to the logical next question, why act at that exact moment), is that only Pycelle knows that a raven has landed warning that winter has arrived. It's also possible Pycelle had just receieved another message Varys wanted to not be passed on (e.g. the "news from Storm's End" that Kevan was expecting).
The common thread seems to be - Varys is making sure that King's Landing is woefully underprepared for what is coming.