Optimus Prime was created in the image of a true leader and ultimate warrior. With the highest levels of integrity and and devotion ingrained in his construction, Optimus is driven to prevent the evil that destroyed his planet form ever repeating again.
It is through happenstance that Optimus Prime comes upon the human race. His fevered pursuit of the Decepticons led him to earth, and his recognition of the good in the human race motivates him to remain the greatest ally of humanity.
Optimus Prime is motivated by the survival of not only his own race, but the human race, and by proxy, the destruction of the Decepticons and Fallen.