Let's put it like this: First the human created the machines with enough AI that caused the machines to vouch for themselves and humans to live together as equal, the humans attacked and attempted to exterminate the machines in retaliation, the machines fought back in act of war and was winning, in desperation the humans tried to cut the machine's main power supply which is the sun by scorching the sky with darkness, then the machines captured the humans and used them as an alternative power source instead of killing them, as time passed the machines and humans made a truce that allowed each side to keep to themselves (machine city), the machines then started growing their own humans instead of capturing and harvest natural ones (natural = non-grown) as an alternative power source, in order to sustain longer life (or power) the machines gave the grown humans a virtual life that simulated the peak of human civilization before disruption began and they can do everything and anything that they can do in real-life, the real/natural humans continued their existences with only a select few here and there that likes to risk hacking into the matrix in order to have fun or create disruption as they please (the Merovingian).
So if you think about it, the machines haven't really done anything wrong. The humans in the matrix are enjoying their life providing they do not go and break the matrix itself (hence the purpose of the agents and neo to either keep people in check or dump them into the matrix-recycle-bin that mirror the post-apocalyptic status of real-life, Zion). All is good excluding the grown humans that cannot accept the matrix program or those that were woken up to hell.
In simpler terms, I think Cypher said it best:
"If I have to choose real-life or the Matrix, I choose the Matrix!"