That's been debated for as long as he was revealed. Mythos of Transformers say that he was created alongside Primus by the Quintessons to be used as tools of war.



But there's another that contradicts that and says that Unicron was created by something called 'The One' to explore the multiverse along with Primus. Primus was favored by the One more, making Unicron jealous and turn on his twin, devouring worlds to regain his lost power.



In G1 show, there's another contradiction. Unicron and Primus were created by a scientist named Primacron and were used to see what was stronger; order or chaos.