The original concept was the machines realizing they had no purpose but to serve humans and couldn’t be “happy” otherwise, but humans were too stupid, violent, and rebellious to ever coexist with.
So the Matrix “serves” them.
The films, especially considering Second Renaissance and the little girl program plus the new movie where the machines are achieving true emotions and independence, still kind of run on the idea. But batteries was easier to explain, preventing being bogged down in exposition like Jupiter Rising was.
Also the machines testing a nightmarish hell Matrix and a heaven Matrix, both of which mankind rejects since all humans can really accept is being a bit of a rebel in the malaise of the 90’s, or how there is a second Matrix they transfer the free thinkers who “wake up” to where the satisfaction of thinking they are struggling against a system keeps them from actually waking up which is why Neo has superpowers in the real world and exists despite the Chosen Ones in that version all just being programs.
But nope. Neo is must psychic to killbots and human batteries are a thing.