Simple. This is the story from the Megatron's story from Wikipedia
In Beast Machines, Megatron's personality underwent a change to become a much darker character. Losing many of his previous personality quirks, he developed a hatred of organics and free will, but oddly saw himself as a savior of Cybertron. His sense of humor vanished, replaced with "Machine Precision" and his plans had evolved to galactic conquest. He even developed some sense of honor, keeping his word to Rattrap in one case where he would have formerly taken advantage of an opponent. However, he still retained his strategic brilliance and manipulative abilities, outwitting the Maximals and other enemies with his plans on numerous occasions.
Megatron as the Vehicon leader in Beast Machines.
Megatron as the Vehicon leader in Beast Machines.
Part-way into the journey back to Cybertron after the end of the Beast Wars, Megatron was able to break free of his bonds and exited the timestream early, returning to Cybertron a considerable time before his Maximal captors. Once there, he adopted a new, zealous philosophy, determining that both Maximal and Predacon alike were threats to the integrity of Cybertron. Megatron came to believe that individuality was the root of all disorder, and envisioned all of Cybertron united as one perfect, technologically precise entity whose destiny was to conquer and consolidate the universe - under his control, of course. Megatron used a virus to hinder transformation and paralyze Transformers and created Vehicon Drones, all under his control. With the population of Cybertron rendered helpless by the virus, the drones slowly captured them and extracted their sparks, their bodies then used as raw material to create more drones. The process went on until nearly all the Transformers had been wiped off the face of Cybertron, leaving only the Vehicons, and Megatron himself, using a control harness to interface with all of Cybertron's systems and his Vehicon Armies, as the singular guiding intelligence at the heart of a single, elegant machine.
In conjunction with his new scheme to erase individuality, Megatron has also developed a fervent hatred of organics, and in his quest to remake Cybertron as the perfect technosphere, dedicated him to the extermination of any and all organic influences on the planet, including his own beast mode. His attempts to purge the organics from his body repeatedly met with failure, and in moments when he would lose control of his emotions, the beast within him would take over, forcing him to detach from his harness and revert into the remnants of his dragon mode. Unable to fully purge the last vestiges of his beast mode from his body, Megatron stubbornly refused to render himself vulnerable even for an instant by simply moving his spark to another body, therefore leaving him trapped in the very thing he hated the most, a partially organic beast form.
When the Maximals emerged from the timestream at their intended point in time, they found the planet under Megatron's control, and were immediately devolved to their original beast modes by the virus. The Vehicons captured Rhinox and Silverbolt, while Optimus Primal, Cheetor, Blackarachnia and Rattrap were able to escape, and were reformatted into technorganic forms by the Oracle shell program of the legendary Vector Sigma computer.
With his technological purity shattered by the arrival of the technorganic Maximals and the revelation that Cybertron had formerly been organic and still possessed an organic core, Megatron bestowed three of his drones with the reprogrammed sparks of Rhinox, Silverbolt and Waspinator, in order to allow them to better combat the Maximals, becoming Tankor, Jetstorm and Thrust respectively. This, however, led to Rhinox's memories and intellect being brought back to the surface by Primal, but, corrupted by Megatron's programming, Rhinox now agreed with Megatron's vision, and set about concocting his own schemes. Duping Megatron and Optimus Primal into using the power of the key to Vector Sigma and the Plasma Energy Chamber, respectively, Rhinox hoped they would destroy each other, leaving him to rule, but when his deception was exposed and the opposing energies released, it only resulted in his destruction. Additionally, when these two energies met in Megatron's citadel, Megatron took a chance and once again attempted to separate his organic and technological sides - only to wind up trapped in the organic half.
Wandering Cybertron in a purely organic body that transformed from humanoid wolf to dragon, Megatron took the name Noble, feigned innocence, and was taken in by the unwitting Maximals, and then exploited them to enable him to return to his citadel, where he transferred his spark into a new, purely technological body, a massive fortress in the shape of his own head, which transformed into a space cruiser. However, his Noble body did not die, remaining purely organic and sparkless, it developed its own primitive intellect.
Floating above the planet's surface, Megatron began anew his scheme for control by acquiring a portion of the Oracle's data from Primal and absorbing the captive sparks into his own, in an attempt to create one, unique intelligence. During this attempt, the Maximals attacked and Megatron killed Noble, resulting in a sonic scream of rage from the Maximal, Nightscream. This scream depolarized Megatron's spark, leaving it wildly flitting around Cybertron, seeking out a new body. Leaping from shell to shell, it found itself unable to remain in a body for long, until Rattrap realized the truth of the matter and repolarized it, trapping it in the frail body of a Diagnostic Drone.
Even as a Diagnostic Drone, Megatron could still access a number of weapon and defensive systems, and he escaped with the help of Strika and Obsidian. Then, his options expended, Megatron submitted to the procedure that would transfer his spark into a new body. His sense of irony intact, the body he chose was based on of Primal's "Optimal" form - minus the beast mode and with a face resembling Megatron's previous incarnations instead of Primal's. With the immense strength and firepower this granted him, he easily managed to fight off Optimus- the only Maximal left standing after the titannic final battle with Megatron's forces-, and, with his long-time enemy unable to do anything but watch, Megatron began the absorption of Cybertron's sparks, growing to a colossal height. Opening a tunnel to the planet's center, Megatron threatened to activate the key to Vector Sigma at its core, transforming the whole world into a perfect technosphere that he would then transfer his consciousness into and then go forth to conquer the universe. Fortunately Megatron could not access the Key while Primal still controlled half of the Oracle, but the massive Megatron simply attempted to separate Primal from the Oracle completely and began to convert Cybertron's organic core. However Primal fought back, overcoming Megatron's power and turning Megatron's throne into organic matter, trapping the Vehicon Leader. Telling Megatron that he needed to find the balance not only between the organic and the technological, but the balance between eternal enemies like him and Megatron, Optimus eventually pushed his foe off-balance, sending the two combatants tumbling down the shaft into Cybertron's organic core. There, together, these two seeds of the future were buried in the past, and, in death, Primal used the Oracle to reformat the entire world into a technorganic paradise.
I hope this helps you.