Comic Bio (US):

When Primus created the Transformer race, he allowed them the ability to procreate through a process similar to cell division, only on a larger scale. Forseeing the danger inherent in this mechanism, Primus "programmed" his creations to "forget" this after a certain point in time.

However, some Transformers regained this memory. Unhindered, the process caused their decendants to lose the inherent morality instilled in them. It also caused another side effect: the creation of a new lifeform, capable of affecting matter on a molecular level. This was the beginnings of the Swarm.

Years later, the Swarm met up with its ancestors, the Cybertronians who were responsible for its creation. In the process of ingesting them, the Swarm (just starting to become "intelligent") learned of the existence of others like them. Like a child bowing to instinct, the Swarm actively began seeking out these other Cybertronians.

Some time later, it came across a Cybertronian battlefleet heading for Earth to reinforce Jhiaxus's troops. After a brief struggle, they too were ingested, and the Swarm headed for Earth in earnest.

Once it arrived, it discovered the rest of Jhiaxus's fleet surrounding Earth. Prepared for the Swarm, Megatron was already preparing to transport the gas rheanimum to the rest of the Autobot- Decepticon army. The gas rendered metal ultra-dense, impervious to even the Swarm's effects. The Cybertronians, however, had nothing equivalent, and were easily devastated. The Swarm also managed to kill several Transformers, including Slingshot, Slag, and Jhiaxus. Others were killed during the battle, although not directly by the Swarm, including Nightbeat, Dirge, and Frenzy.

Optimus realized the futility of fighting off the Swarm forever, and with the recently regained Matrix inside of him, allowed the Swarm to ingest him. With the Matrix keeping him alive well beyond the point of death, Optimus was able to communicate the moralities and wisdom of the Matrix to the Swarm. This, as it turns out, was exactly what the Swarm needed. Newly matured, the Swarm recreated and improved Optimus's body and deposited his mind into it, before leaving the Sol system. It is unknown whether or not the Swarm may have done the same for anyone else it had ingested.