Optimus Prime is a difficult character to write for because he is the saviour archetype. But not impossible. He's much like Superman or Captain America; the boy scout known for having no real character flaws, and that's what makes these challenging characters to write for. On one hand, flaws/weaknesses can make characters interesting, but on the other hand you don't want to make a heroic character flawed to the point that it digresses away from the spirit of that character.

The Right Way

Examples of how this can be done well:
* Superman (Christopher Reeve)
* Wonder Woman (2017)
* Captain America (MCU)
These are your goodie two shoes heroes and heroine with no discernible character flaws. These characters don't fight evil because they feel obligated to but because they know it's the right thing to do. They just want to help to make the world a better place. This is quite different from heroic characters like Batman, Spider-Man or Iron Man who feel a strong sense of obligation (with great power yada yada yada). I feel that Optimus Prime would be best served being written from this perspective, at least in the beginning as Orion Pax and even as Optimus Prime on Cybertron. The G1 comics did make him an obligated hero because he was riddled with guilt for bringing the Cybertronian war to Earth and endangering its inhabitants -- so if people would rather see the obligated hero then that can work too by shifting his character later. But his character would have already been built up by a lot of his unobligated works.

Take Captain America for example. He was initially used just for war propaganda to sell war bonds and entertain the troops, nothing more. But he always felt the strong desire to just help people because it was the right thing to do. This was part of Steve Roger's character even before he became Captain America. We see him attempt and fail to enlist several times. We see him stand up to a bully larger than himself, with that iconic line of, "I can do this all day." The reason why Professor Erskine chose Rogers to be the recipient for the Super Soldier serum was because he felt that he was worthy. He didn't want that power falling into the wrong hands -- Steve Rogers was already a top bloke before he got his powers. He was already desperately trying to be a hero. I think that Orion Pax could be written in a similar way.

The Wrong Way

I think that the way you don't handle this character is similar to the way that we've seen other saviour like characters written. So you do not...
* Make him a Gary Stu. It's why I hate reading fan fics.
* Make him dark, menacing and/or brooding. This would take him away from being Optimus Prime, and we've seen this in the Bayformers sequels. We saw DC do this with Henry Cavill's Superman.

But the most important thing...
...and this is something that Travis Knight understands all too well and is something that's been sorely missing from Bayformers -- MAKE THE CHARACTER RELATABLE. That's it. That's the key ingredient. You can make him godlike and all, but he must be relatable. Captain America is a relatable guy. Dr Manhattan, not so much (not that he's meant to be). The audience must be able to emotionally invest in the protagonist. This is what's made Bumblebee work so much better as a story over all other TF films. We need to care!