The Swarm was a parasitic, virus-like entity which could assume many forms.
The Swarm worked like a disease, spreading through electrical pulses which needed to make contact with a victim's eyes. This would turn victims into agents of the Swarm, answering to a Nucleus, a microscopic and virus-like sentient organism that controlled the swarm. Visually, an infected lifeform could be recognised by the growing of grey filaments around their eyes and hands.
The Swarm lay dormant in cloud-like anomalies in space, including the area near Saturn for untold millennia, until spaceships passed through them. In the year 5000 it was picked up by the crew of a passing spacecraft. It infected the relief crew for the Titan Base, and through them eventually most of the Bi-Al Foundation, located on Asteroid K4067.
Certain individuals (such as Leela) had antibodies that could defeat the virus. Additionally, the progress of the virus could be slowed simply by not thinking. Known victims of the Swarm included the Fourth Doctor, K9 Mark I, Professor Frederick Marius, the crew of the Titan Base and most of the Bi-Al Foundation. (TV: The Invisible Enemy)
The Swarm remained dormant in the TARDIS' computer until the Doctor's seventh incarnation. Shortly afterwards, the Doctor returned to Titan Base in the company of Ace and Hector Thomas in 4920. The TARDIS had been commandeered by Hector, who had fallen under the control of the Swarm. It ensured its own creation by returning to the Bi-Al Foundation, where it mutated from the Saturnian plague.
While in 4920, the Nucleus 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. (AUDIO: Revenge of the Swarm)