The Swarm is a cloudlike black mass, accidentally created by a misuse of the form of Transformer reproduction called budding, under the direction of the Liege Maximo and the Cybertronian Empire. Though very different from Transformers on the surface, its genetic material and cellular structure are identical to the Transformers, betraying its origin. It seeks out and destroys life, literally "eating" mechanical (but not, apparently, organic) living beings, in a fairly horrific fashion. The Swarm is hollow and blindly hungry for the soul/power/mission of Primus that it lacks, and so is drawn specifically to Transformers, though it will eat other forms of life in its blind attempts to complete itself.
Marvel Comics continuityEdit
Optimus Prime fed both himself and the Matrix to the Swarm, filling it with Primus's vision, and hence turning it into a force for creation rather than mindless destruction. In an attempt to make amends, it recreated Prime in a new body, before departing.
3H comics continuityEdit
(Extra-canonical comments from the Beast Wars creators suggested that the Swarm eventually evolved into the alien race known as the Vok. The details of this were discussed but never formally decided upon and did not make it into the show. The 3H fan club material was intended to solidify this connection, but does not go into very specific detail.)