artifice
They were the villains. It's established in the animatrix set of short films, that the machines did not perceive themselves as villains, and this is a common characteristic that cuts across most tropes of villainy. During a monologue, a villain will often equivocate their motivation with that of the hero. (you and me? we're really the same...)
Focus groups and producers interfered with that aspect of the plot (the grid computer made of people, hence the name: The Matrix), and rewrote the story to depict the machines as using humans as an energy source, a power grid (changing puns and quips using, instead of computational terms, to energy references, such as "coppertop" and the like), which tested as a more accessible concept to the lowest common denominator in the target audience.
If you watch the supplemental material included with the trilogy boxed set, I think it's mentioned in either one of the commentaries or the documentaries and interview segments.