Prolonged hatred and discrimination from humans eventually escalated the war, to the point where the more warlike machines finally took control and subjected humankind to The Matrix.
Oddly enough, The Matrix series is actually one of the few stories that are improved by a more fleshed out and less ambiguous backstory.
The Animatrix — a number of short films that tie into the main trilogy — performed this duty brilliantly back in 2003 and expanded upon the foundation for the movies.
What the movies don’t show us, that The Animatrix does, is that the machines were a relatively peaceful group of individuals who wanted nothing more than equal rights and sovereignty.