Keep in mind, Megatron (along with Starscream and Sentinel Prime) weren't exactly diabolical. Each one had their own agenda for their race and planet. Up until the final film, humans were never targets.

Exactly. Sentinel Prime saw himself as a god over humans, and believed he had the right to enslave them. He was the one who taught Optimus that freedom is the right of all sentient beings, and Optimus knew that he was not the same Sentinel that he once knew and respected. He was a Decepticon now, and it was Optimus Prime's responsibility as the leader of the Autobots to destroy him. As long as Sentinel lived, humans would never be safe.