The wise and powerful Autobot commander Optimus Prime began his function cycle as a young Autobot named Orion Pax.Pax was a naive young worker robot, who, along with his girlfriend Ariel and his best friend Dion, shipped Energon cubes at a warehouse on Cybertron. Pax looked up to the robot called Megatron, the first in a new line of military robots, who could fly in robot mode. However, Pax's idolisation of Megatron proved to be his undoing, as the evil robot quickly gathered an army with which to overthrow the benevlolent Autobots. Requiring energy to power his conquest, Megatron attacked Pax and his friends, stealing their shipment of Energon. The comatose and dying Pax was brought to the Cybertronian machinesmith, Alpha Trion, by five warriors (later revealed to be the time-displaced Aerialbots. Trion rebuilt Pax into Optimus Prime.
Optimus Prime went on to assume leadership of the Autobots in the Third Great War, as his hatred of Megatron grew. When the war used up all of the available energy sources on Cybertron, Prime hit upon the idea of searching out other planets rich in energy. Assembling a small contingent of soliders, Prime ventured out into the galaxy in the Autobot spaceship known as the Ark.However, the Decepticons wanted whatever energy the Autobots found for themselves, and followed the Ark, until it had cleared an asteroid belt, when they boarded it. In the ensuing conflict, the Ark went out of control, and was caught in the gravity of the third planet of the Sol system. The crash deactivated all Transformers on board, putting them in emergency stasis.
Four million years later, a freak eruption revived Teletran 1, the Ark's computer, which in turn repaired and reactivated both the Autobots and Decepticons. Prime was given the Earthen form of a semi-truck, with Prime as the cab,and the trailer capable of transforming into a battle station.And so the wars continued on Earth, albeit on a smaller scale, and the humans came to accept and respect Optimus Prime and his Autobots.
Despite Prime's best intentions, by the Earth year 2005, the Decepticons had taken control of all of Cybertron. Prime, operating from a secret base on Cybertron's first moon, deployed some soldiers to Autobot City on Earth to collect energy to power the coming attack on Cybertron. However, Megatron intercepted the shuttle, and flew it to Earth, where the Decepticons viciously attacked Autobot City. Responding to a distress call, Optimus Prime arrived at the city with reinforcements, and faced off with Megatron for the last time. Due to accidental interference by the young Autobot, Hot Rod, Megatron was able to blast Prime through the stomach several times. With the last of his strength, Prime was able to inflict fatal damage to Megatron also. Perceptor tried, but Prime succumbed to the severity of his wounds, and passed the Autobot Matrix of Leadership on to Ultra Magnus before he died.
A year later, the evil aliens known as the Quintessons recovered Optimus Prime's body and reanimated it into a living-dead state.
The zombie-Prime destroyed the Autobot Mausoleum, but eventually overcame the Quintesson influence, and piloted his ship into a nearby sun, causing it to go nova.Prime was seemingly destroyed.
However, shortly thereafter, it was revealed that two humans, Gregory Swafford and Jessica Morgan, had intercepted Optimus's ship before the sun went nova, and taken his body back to Earth. When the sun exploded, their craft was covered with solar spores, which were discovered to be a virus which manifested hatred. The spores began to spread throughout the galaxy, driving everyone they infected totally insane. A Quintesson made a deal with the Autobots, and totally restored Prime to life. Prime then opened the Matrix and destroyed the Hate Plague with the wisdom contained within.
Prime then began to have premonitions after opening the Matrix, and journeyed to Vector Sigma, so that he could speak with his creator Alpha Trion to learn what he should do to stop the Decepticon leader Galvatron from gaining the power of the Plasma Energy Chamber. Alpha Trion revealed that he had allowed Galvatron to learn of the Chamber, as he knew what would result from the conflict. When Galvatron tried to use the energy in the chamber to force Earth's sun to go nova, Spike Witwicky and Fortress Maximus rerouted the surplus energy back to Cybertron, re-energising it, and restoring Cybetron's Golden Age.
(NOTE: It is unlikely that the restoration of the Golden Age actually ended the Great Wars. As both Prime and Galvatron were functional, it is probaly safe to assume that the wars continued for some time after this. Optimus Prime's status at the time of the Beast Wars is unknown).