Zero's purpose only ever was as basically a robot killer to top all robot killers. Initially, just to defeat Bass and Rock, and after he learned of X, changed that to "destroy X". Either way though, Zero was ALSO always Wily's magnum opus. To be his greatest creation which would prove how much better and smarter he was than Light.
Hard to say what *exact/specific* purposes Wily made the virus for, there are a few Ideas.
The biggest one, to pacify and control Zero. We know Zero was ealed away do to a cognitive program flaw that made him extremely violent and disobedient. When he was infected in his fight with Sigma, he became normal. Under the scenario that he is bombarded with virus in X5 if you fail the shuttle, he becomes cold and uncaring, "awakening" and remembering his original mission and unbiasedly accepting it, despite all the time he has known X. The Virus also acts as some sort of power source for Zero as well, making him stronger.
It's ALSO possible, and likely, that Wily's revival "through the virus" was planned as well.
And it's also possible he wanted to try and repeat his plan from 10, virus to make robots go nuts/control them, and the wrench in the works was that Sigma bonded with his virus and Zero, being infected as well, forgot his mission and became a normal level headed reploid.
On X- Both X1 and MHX seem to suggest that Light considered the idea that robots needed to have complete and true free will, the kind X has- and also figured the future would need someone like Rock to protect them. So he made X. He also figured that after the events of 10, that X might fight robots with similar viruses in the future, and gave him perfect virus countermeasures.
But nothing to suggest that Light had learned of Zero, OR that Duo had any influence.
Though then again, if the Evil alien robot was what inspired Wily to make airborne energy based viruses, then its certainly possible Duo inspired SOMETHING.