Optimus Prime was a Cybertronian and leader of the Autobot forces.
Millions of years ago, Cybertron fell into civil war, Optimus emerging as the leader of the Autobot army. The destructive force of the conflict ripped Cybertron from its orbit and causing it to become a rogue. When Cybertron drifted into the path of the Sol asteroid belt, four million years prior to the 23rd century, Optimus launched a starship that blasted a path through the rocks. Before the Autobots could return to Cybertron, Megatron's forces struck, boarding the Autobot spacecraft. Out of control, the ship crashed into a volcano on the nearby Earth, knocking all combatants into stasis.
In the 1980s, the volcano erupted, reawakening the Cybertronians who began a secret war for Earth's supply of energon, the Autobots even building a city. A handful of humans would find themselves involved in the Cybertronian war which proved a source of great guilt for Optimus. The Cybertronians remained on Earth to witness the whole of the Eugenics Wars and the start of World War III. Deciding Earth was too dangerous a world, Optimus ordered his troops to leave the planet aboard Fortress Maximus. The Autobots journeyed for decades until they came across Cygnus Seven, which held a rich bounty of energon. Before they could land, the Decepticons struck, and once again sent the Autobot ship hurtling towards the primitive planet out of control with all aboard winding up in stasis lock.
In the 23rd century, the United Federation of Planets had moved onto Cygnus Seven with a dilithium survey team inadvertently reacting Maximus' autonomic systems. Once the Titan had repaired the Decepticons, his systems revived Optimus who ran after his foes. (TAS - Star Trek vs. Transformers comic: "Issue 2")
When Optimus arrived, his now archaic vehicle mode was mistaken for a remote controlled Klingon weapon by James T. Kirk who fired the full power of his phaser at Prime. Still not fully healed, Optimus fell back into stasis but was able to impart onto Kirk his good intentions and familiarity with the human race. When the Decepticons had been scared away, Kirk ordered his crew to begin fixing Optimus. (TAS - Star Trek vs. Transformers comic: "Prime's Directive, Part One")
With Cybertronian internals proving too complex for either Scotty or McCoy to make sense of, Spock utilized the Vulcan mind meld to jolt Optimus back to life. Once Optimus had acquainted himself with the organics, he led them back to the mineshaft where Maximus was buried only for Starscream's force to strike, backed up by Kuri's Klingons. (TAS - Star Trek vs. Transformers comic: "Issue 2")
Though the quartet attempted to defend the colony, they were outmatched by the Decepticons until Fortress Maximus, now reformatted into a copy of the USS Enterprise, entered the battlefield. When Megatron ambushed the weakened Optimus, Maximus transformed to robot mode to fight Trypticon. (TAS - Star Trek vs. Transformers comic: "Issue 3")
Though Optimus tried to fight Megatron, his weakened state resulted in him being defeated by his arch-enemy before Jazz and Windblade arrived. The battle came to an abrupt end when Megatron ordered his forces after Starscream, who'd absconded with a supply of dilithium and was making his way to Qo'noS. As the Autobot/Starfleet alliance made plans to pursue, the Autobots were beamed aboard the Enterprise, disabled by Trypticon, so Cybertronian engineering could restore it to working order. (TAS - Star Trek vs. Transformers comic: "Issue 4")
During the flight, Optimus and Kirk spoke about the burden of leadership, Prime's words inspiring Kirk to use the replicators to create the "Crewbots", Cybertronian scaled mechas that the Enterprise crew could use to fight the Decepticons on even footing. When the group arrived in the First City however, they were defeated by Soundwave's audio disruptor waves only for the Klingons, deaf to the frequency Soundwave used, to summon a fleet of D7s that defeated the invaders.
In the aftermath, both Autobots and humans were allowed to go free by the Klingon High Council, so long as the Decepticons remained in Klingon custody. Though Kirk invited the Autobots back to the now peaceful Earth, Prime denied, confident that his people's destiny lay elsewhere in the universe, but swore to come to his new friends' aid should they every need it. (TAS - Star Trek vs. Transformers comic: "Issue 5")