Unicron was a colossal Transformer that was built by the Primeacon in a vain attempt to clear all life in the galaxy to leave him a clean slate to start upon, Of course, Unicron decided against it and set of into space.

Planet form.

Many years later, 2005 to be precise, Unicron arrived at the small planet of Lithone. He then quickly ate it and moved on, a few survived the disaster. On his travels, he became aware of the death of Optimus Prime, who gave the matrix of leadership to Ultra Magnus, shortly before dying, angering him at the same time. He came across several dead or dying decepticon bodies among them being Megatron. Unicron transformed them into newer stronger versions of themselves.
Later on, Unicron descended upon cybertrons two moons and devoured them both. Enraged at Galvatron (the new megatron) forget back, but was stopped by Unicron's mind powers, instead Galvatron comanded his superpowered decepticons to chase the surviving autobots, until they eventually arrived at a junk planet, were Galvatron managed to capture the matrix of leadership and return it to Unicron, but Galvatron decided to again try and betray Unicron, but Unicron simply swallowed him. He then descended upon Cybertron, many transformers decepticon and autobot alike fight against Unicron. Ultra Magnus drove through Unicron's eye only to come into contact with Galvatron. A fight ensured and Galvatron was winning until Magnus retrieved the matrix from him and transfomed into Rodimus Prime. He grabbed onto Galvatron and smashed him out the side of Unicron and out into space. He then used the matrix inside Unicron destoying him from the inside. The last thing seen of Unicron is his massive head floating off into space.