Credit goes to Wikipedia
Sixty-five million years ago, an alien race known as the “Creators” used devices called Seeds to cover Planet Earth with an alloy that will one day be dubbed “Transformium”. In the present day, geologist Darcy Tyril excavates the Transformium for K.S.I. Industries, which uses it to build man-made Transformer drones.
Five years after the Battle of Chicago, humans have begun to view the Transformers as a threat, leading the U.S. government to terminate all human-Autobot joint programs. Although the public believes the Autobots were granted sanctuary, they are being hunted by a rogue CIA black ops division known as Cemetery Wind, led by opportunistic government official Harold Attinger, who believes all Transformers should be exterminated regardless of their faction. They are aided by Lockdown, a neutral Cybertronian bounty hunter working for the Creators, promising to give Attinger a Seed if his division manages to capture Optimus Prime. Cemetery Wind locates Ratchet in Mexico City and Lockdown kills him when he refuses to give up the whereabouts of Optimus Prime.
Optimus, damaged in Mexico City and disguised as an old Marmon 97 semi-truck, is discovered in an old theater by Cade Yeager, a financially struggling Texan inventor, and brings him back to his farm. While his teenage daughter Tessa and business partner Lucas Flannery encourage him to turn Optimus over to the authorities after realizing what he really is, Cade instead fixes Optimus, hoping to understand his technology and unexpectedly revives him. Hoping to collect a reward for turning Optimus in to the government, Lucas calls the authorities, which gets redirected to Cemetery Wind, who, led by Lockdown and Attinger’s second-in-command James Savoy (who hates Transformers because he lost his sister in Chicago), attacks and destroys the farm, but Optimus and Tessa’s boyfriend, Irish rally car driver Shane Dyson, come to the family’s aid. While escaping Cemetery Wind and Lockdown, Lucas is killed by one of Lockdown’s grenades. Out in the desert, they seek refuge in an abandoned gas station. Later, Optimus gains an alternate form after scanning a passing Western Star 5700 XE Phantom Custom truck with the original red and blue paint with flames (healing his injuries in the process) and summons the surviving Autobots – Bumblebee, who has assumed a new alternate form (a modified 1967 Chevrolet Camaro), Hound, Drift, and Crosshairs – who have come to distrust humans due to Cemetery Wind constantly hunting them down. Using a CIA drone which he stole during the home invasion, Cade discovers K.S.I.’s involvement in the attacks on the Autobots. Optimus vows to personally kill Attinger for his actions against his brethren.
Infiltrating K.S.I.’s headquarters in Chicago, Cade discovers the dead Autobots and Decepticons are being melted down to make the drones. Joshua Joyce, the ambitious company CEO, is in league with Attinger to revolutionize global defenses and improve human society using the Seed. He has captured Brains and used him and data from Megatron’s head to create the drones and prototype Transformer soldiers Galvatron and Stinger built from the Transformium harvested from Cemetery Wind’s kills. Enraged after seeing their dead comrades being melted down for scrap, the Autobots storm the building, during which Bumblebee gains an upgraded form by scanning a passing 2014 Chevrolet Camaro Concept, where they rescue Brains and destroy the laboratory, but they leave after Joshua announces they are no longer needed. Attinger forces Joshua to deploy Galvatron and Stinger to attack the Autobots. During the battle, Galvatron’s behavior becomes slightly erratic when it starts destroying vehicles, and when it fights Optimus it speaks to him. Lockdown then arrives and abducts Optimus while Galvatron and Stinger retreat; Tessa is inadvertently captured alongside Optimus in the midst of the chaos, leaving Cade and Shane devastated.
While Lockdown’s large prison spacecraft hovers over Chicago to hand over the Seed, Cade, Shane, and the Autobots use the opportunity to sneak onboard and rescue Optimus and Tessa, hijacking a smaller ship containing a group of ancient Autobot warriors known as the Dinobots, just before Lockdown leaves Earth. The Autobots reveal to Cade that “Galvatron” is in fact Megatron, who gave K.S.I. the data to build the Transformer drones so he could transfer his consciousness into the Galvatron drone, after they unknowingly revived him. What’s more, Galvatron is plotting to use the Seed and the K.S.I. drones to conquer the world by detonating the Seed in Hong Kong, as K.S.I. has brought it there to use in the remote Mongolian desert to create vast amounts of usable Transformium, and build an even larger army to conquer the Earth and spread through the galaxy. Cade informs Joshua about Megatron’s presence in Galvatron, causing him to have a change of heart and agreeing to hand over the Seed with help from Darcy and his Chinese business associate Su Yueming. Meanwhile, Lockdown discovers Optimus’ escape with the Dinobots, and returns to Earth to recapture them. Optimus decides after getting the Seed, the Autobots will no longer help the humans because of how they distrusted and killed their kind, and now revived Megatron, but Cade explains to Optimus why he shouldn’t lose faith in them. At the K.S.I. facility, during a disagreement between Joshua and Attinger over the Seed, Galvatron reactivates himself and promptly takes control of the K.S.I. drones, and a battle follows in Hong Kong’s streets between Cade’s group, the Autobots, Cemetery Wind, Galvatron, and his drones. During the fight, Savoy is killed when Cade pushes him off a building. Taking a sword and shield from the ship’s armory, Optimus frees the Dinobots and gains their allegiance by defeating their leader in a trial by combat and they become essential to the Autobots’ victory while Bumblebee kills Stinger.
Lockdown returns to capture Optimus and the Dinobots, using a large magnet in his ship that picks up and drops metal objects, causing destruction to the city. After disabling the magnet, Optimus fights Lockdown at an abandoned factory. In the ensuing duel, Optimus kills Attinger (who still angrily deems all Cybertronians as a threat) to save Cade, and avenging the deaths of his fellow Autobots, but he also lets his guard down and this allows Lockdown to pin Optimus down by impaling his chest with his own sword into a nearby stone wall. Cade, Bumblebee, Tessa, and Shane fight Lockdown, with Cade ending up fighting him one-on-one while Tessa and Shane use a tow truck to free Optimus, who kills Lockdown by cutting him in half before using one of his grenades to finish off the remaining drones. Galvatron retreats, vowing to return.
As Lockdown’s ship leaves Earth, Optimus tells the Autobots to protect the Yeagers (with Joshua offering to help the Yeagers build a new home) and lets the Dinobots go, before flying away into space with the Seed to hide it away, sending a message to the Creators to leave Earth alone because he is coming for them.