First appearing in Action Comics #242 (July 1958), Brainiac was a bald, green-skinned humanoid, who arrived on Earth and shrunk various cities, including Metropolis, storing them in bottles with the intent of using them to restore the (unnamed) world he ruled. He was accompanied by a "space monkey" named Koko.
While fighting Brainiac, Superman discovered the villain had previously shrunk the Kryptonian city of Kandor. He was able to restore the Earth cities to full size, but the Kandorians sacrificed their restoration to help him. Superman stored the city in his Fortress of Solitude, vowing to return the natives to full size.
Brainiac's legacy was revealed in Action Comics #276, in a Legion of Super-Heroes back up story. This introduced the green-skinned, blond-haired teenager Querl Dox, or Brainiac 5, who believed himself to be Brainiac's 30th century descendant. Unlike his apparent ancestor, Brainiac 5 used his "twelfth level intellect" for good, and joined the Legion alongside Supergirl, with whom he fell in love. His home planet was given variously as Yod or Colu.
In Superman #167 (Feb 1964) it was discovered that Brainiac was a machine, created by the "Computer Tyrants of Colu" as a spy. To increase the illusion that he was alive, he was given a "son", a young Coluan boy who was given the name Brainiac 2, but escaped. This was Brainiac 5's ancestor. It was later revealed that his name was Vril Dox, and that he went on to lead the revolt against the Computer Tyrants.
It was in this story that Brainiac first appeared with a distinctive gridwork of red diodes across his head, later explained as the "electric terminals of his sensory nerves". This would remain his appearance until Action Comics #544 (June 1983), in which he was forced to create a new body, a metallic skeleton with a green, honeycomb-patterned "braincase". He retained his appearance until the Crisis on Infinite Earths.
In the Post-Crisis DC Universe, Brainiac's history was dramatically altered. Vril Dox was now a radical Coluan scientist who, having attempted to overthrow the Computer Tyrants, was sentenced to death. In his last moments, his consciousness was attracted to Earthly sideshow mentalist Milton Fine, who worked under the alias "Brainiac". Needing cranial fluid to maintain his possession of Fine, Dox went on a murder spree. He discovered Fine had genuine psychic powers, which he frequently used on Superman. This version of Brainiac made his first appearance in Adventures of Superman #438 (March 1988).
Brainiac was later captured by Lex Luthor, but used his powers to wrest control of Lexcorp away from him. Under his mental domination, Lexcorp scientists restored his Coluan form. The diodes in his head now increased and stabilised his mental powers, as well as allowing him direct access to computer banks. He continued to plague Superman, using a combination of mental powers and computer control. On one occasion he even returned to his pre-Crisis incarnation's city-shrinking tactics.
In the crossover story Invasion! it was revealed that, prior to his dispersion, the Computer Tyrants had allowed Vril Dox to clone a lab assistant. This was Vril Dox II, who would go on to form L.E.G.I.O.N., and (although he never uses the name) is the post-Crisis version of Brainiac 2.
To confuse things further, following the loss of Milton Fine's body, Vril Dox would place his consciousness in a robot body he called Brainiac 2.5. He became briefly obsessed with gaining Superman's form.
At the turn of the millennium, Brainiac revealed he had placed a sleeper virus in Lexcorp's Y2K bug safeguards. This was intended to dramatically boost his abilities. Instead it allowed Brainiac 13 to arrive from the 64th century. B-13 began transforming Metropolis into the 64th century version of the city, which, apparently, he controlled. When it became apparent he was to be defeated by the combined efforts of Luthor, Superman and his own past self (now possessing Luthor's infant daughter), he gave control of the city to Luthor in exchange for Lena/Brainiac 2.5, who he forced to help him escape.
He returned to Earth during the Our Worlds At War crossover, in which Earth and its allies fought a multifront war against Brainiac 13 and Imperiex. Brainiac 13 claimed to be allying himself to Earth, but this proved to be part of a complex plan to regain control. His chief aide was "Leniac", a green-skinned teenager with "control discs" on her forehead, suggesting the diodes of earlier Brainiacs (and identical to the forehead discs of the "upgraded" Brainiac 5.1, in the Legion, and the Animated Series version of the original Brainiac).
At the end of the war Brainiac 13 and Imperiex were both sent back in time, becoming part of the Big Bang, and Brainiac 2.5 was expunged from Lena, who reverted to infancy, although the discs remained.
In Superman #200 (Feb 2004), Superman travelled into the future and battled Brainiac 12, learning that everything Brainiac 13 had done in the past had been designed to ensure things reached the point where Brainiac 13 would be created. B-12's defeat before his upgrade apparently reversed the advances B-13 had made to Metropolis.