It is their job to exterminate them. It doesn't make them just like the Decepticons. The only difference between the Autbots and Decepticons, anyway is that Decepticons will go to extreme measures to get what they want. Neutralizing a threat is not an extreme measure. And how the hell wouldn't Optimus know about what happened to Ironhide? You don't think someone would have told him what that huge pile of rust out in front of the base was? Also, Optimus would never accept a truce with the Decepticons. Why should he after all they've done?
Anyway, I think that was done to show how war changes people. Optimus started off begging for peace, and Megatron started off being ruthless. And at the end of DOTM, they had both basically taken each other's positions. It's irony...
...In real life, you don't get the chance to take the "moral high ground." Movie Optimus is more of a realistic interpenetration of what Optimus Prime was. It's kill one to save thousands.
In a realistic interpretation, Optimus would have been tried as a war criminal for not taking the moral high ground (heck Impactor was tried and imprisoned for doing exactly what Prime does here). As a character he's supposed to be the hero, moral archetype that we all should look up to which includes mercy. I think someone else already mentioned that this version of Prime is more akin to the Punisher than anything else, who is not a heroic character. I'd be fine with this portrayal of Prime if the needs of the many thing was actually explored in the movies, like it was in the Prime TV show. But here, the brutality is exploited for spectacle without any serious attempts at building these characters.
In terms of saving people though, Prime isn't very good at that here either as he decides to follow a plan that engages a dangerous fugitive in a highly populated area, probably resulting in the injury or death of a couple hundred along the way. Again, if this issue was explored at all, I'd be fine with it, yet they still choose to characterize Prime as this figure for all that is good and just despite not doing that in his actions.
It would be nice if the movies themselves appreciated the ironies they keep creating, but the Autobots and Decepticons in these things started off the way they are and keep up their brutal ways throughout.