No matter what happens in Transformers lore, whether it's in animated movies, cartoon series, comics, toys or live-action films, fans want to see Optimus Prime. The leader of the Autobots is undoubtedly the face of the franchise, loved all over the world.
With IDW's recent comics, while a lot of the mythos has been retconned, Optimus remained a paragon of virtue. However, come Transformers: Unicron #6, his duty is over, as the 13th Prime has finally met his end, sacrificing himself to destroy the eater of worlds.
The Unicron event has been IDW's flagship event this year, bringing back the fan-favorite villain for one more feast. But before we get to why Optimus sacrifices himself, we have to understand how he was left no choice, trying to atone for the sins of his ancestors, the Primes. In this reshaped lore, we find guilt on Optimus' shoulders as it's been revealed the legacy of the Primes was colonization, not heroism. They were conquerors masquerading as knights, which is why the military leader Orion Pax (Optimus in his youth) and Megatron rose up and tried to save Cybertron. Before they became enemies, they wanted to fix what it stood for in the past.
As the Cybertronians moved in on one more target, Antilla, a scientist who lost his family due to the invasion created a device called the Talisman which would turn it into the war planet called Unicron. Through his programming, Unicron's been seeking out and devouring every single Cybertronian colony. Sadly, as much as Optimus wants to wash this legacy of blood away, he has to do so by killing Unicron, especially because now that he's eaten Cybertron, Earth is the last colony standing in his lifelong mission of revenge.
Optimus tries to figure out alternative plans, but the return of Shockwave (Onyx Prime) really messes things up. It turns out Shockwave, known as Onyx Prime in the past, reactivated Unicron so it could devour all life in the cosmos, allowing him to create new planets and, of course, new life. Shockwave was banking on using the Talisman himself, but as fate would have it the relic fell into Optimus' hands and he once more saved the day.
And he's all too ready to do so, because he's seen a new era rise -- one of unity. G.I. JOE, M.A.S.K. and COBRA are united on Earth, and, most notably, the Autobots and Decepticons are now allies again (granted, it's an uneasy alliance). He's watched Megatron, Soundwave and even Starscream turn into heroes recently, so Optimus actually welcomes this suicide mission to take the Talisman to Unicron because, well, he's simply tired of war.
Just like Star Wars' Death Star, Optimus finds the weak spot, a black hole in Unicron's chest, which, once the Talisman is dropped in like a bomb, will turn on and eat the mammoth robot itself. It's ironic because this black hole powers the monster, drawing power from stars across the galaxy when he feeds to help run his engine. As fate would have it, it's now the means to his downfall.
And so, Optimus exploits this weakness, backed by Arcee, as they all die heroically. But before they do, Optimus himself goes into Infraspace (the realm between life and death), where he meets the unnamed scientist who turned Antilla into Unicron, and finally gets to apologize for his ancestors. He's eventually forgiven and in the blink of an eye, Unicron is destroyed, with Optimus and the other robots inside disintegrating into the black hole.
It's a really breathtaking read for fans who saw him die in the 1986 animated Transformers movie, which was coincidentally Unicron's debut. Well, it's a heroic death, done way better than when Michael Bay tried to kill Optimus off in his movies; it's substance over style and, ultimately, it's how the leader would want to go out.