Depends on when in our history. Originally machines were created for the purpose of combat to negate human casualties. They eventually turned against their creators and quickly overwhelmed humanity and began to burn through all of Earth's resources. As a last resort Project Zero Dawn was created with the aim of restoring Earth once the machines ran out of resources to consume and went offline.
The machines from Zero Dawn were created to terraform the planet back to a useable state at which point life would begin again. For many years we did live in a pace with the machines, or at least close to. However there was a signal that cause the subordinate functions to change and the machines became more and more hostile.