The Virus of the Purpose, also known as the Swarm, is the main antagonist of the Doctor Who story The Invisible Enemy. It would later reappear in the Big Finish audio play Revenge of the Swarm.
The Invisible Enemy
The Virus of the Purpose was a sentient, space-dwelling virus, capable of gaining controlling of anyone it infected. Its first victims were the crew of a shuttle en route to Titan who, upon arriving, killed most of the crew of the Titan base and began turning it into a breeding centre for the Swarm. The Virus also infected the TARDIS and the Fourth Doctor, who became the host for its Nucleus, although Leela was immune. Two of its carriers were killed, but the Virus managed to infect the surviving base crewmember, Supervisor Lowe, who covered for the fact that one of the Virus' hosts, Safran, had survived.
Lowe accompanied the Doctor and Leela to the Bi-Al Foundation, where he spread the Virus to several of the staff. The Virus also infected a shuttle crew and caused them to crash into the foundation as a distraction. The Nucleus was removed from the Doctor and enlarged to macro-size, being taken back to Titan by Lowe. The Doctor managed to cure those infected at the foundation and headed for Titan with antibodies obtained from Leela, but they were destroyed. The Nucleus was preparing to spawn macro-sized Virus molecules but the Doctor set up a booby trap with a laser gun and an oxygen leak, causing the base to be destroyed.
Revenge of the Swarm
Years later, the Seventh Doctor, Ace and Hector Thomas learned the Virus had remained dormant in the TARDIS computer and infected Hector, as he was more susceptible to control as he had lost his memories of his past life as Hex. It travelled back to Titan Base in 4920, 80 years before the events of The Invisible Enemy, where it infected several of the staff, and ensured its own creation, where it was hyper-evolved from the Saturnian plague. The Swarm's minions were also able to launch the original Nucleus into space before it could be destroyed, prompting The Doctor to speculate that its accelerated evolution was the reason that the Swarm he encountered in 5000 claimed to have been adrift for millennia despite only being created eighty years ago, as the process warped its perception of time.
The Virus cloned itself and uploaded its mind to the Bi-Al Foundation computer. It then used the TARDIS to travel forward in time to the 52nd century, by which time the centre had become a Hypernet relay station. Using the TARDIS' Relative Dimensional Stabiliser and the power of the Hypernet, it intended to recreate itself and become corporeal. However, it was defeated by the Doctor, Ace and Hector when the Doctor was able to trick it into trying to reinfect Hector after he had treated Hector with his own antibodies, disrupting the Swarm's control of the Hypernet long enough for its physical body to be destroyed, The Doctor ensuring that all traces of the virus were purged from the TARDIS to prevent a repeat of this experience.