TLDR scenarios, please scrool to the last line! :)
A try to do it without spoiling...
You have to decide whether you trust machines (to some level...) or not, yourself. See Oracle speech in Reloaded.
If you trust them...
The machines don't need this energy. See Architect speech. This means they simply use it because it is available as a side-effect and machines don't do waste.
The important thing is that they are not for the energy. What are they after for?
There are two possibility. The machines need humanity as an equipment for doing whatever they are doing, because it is convenient. Or the machines can use noone else but humanity for something they lack from themselves - in which case they need humanity, not only use.
See Hamann speech.
My hypothesis is either the catastrophic environment of the machines constraint (forces or motivates) them into working on something, in which they find to use humans convenient for; or they lack something not built into them, something that is missing from their very design (themselves), but humans have it, and they extract it; or both.
To combine Scroff's answer into mine, the machines may need (lack) the free will of humans, and the whole matrix thing is because humans tried to destroy them so they do not dare to unleash free will but try to maintain control over it, so to keep it useful and safe.
To further combine Aaron Lowe's answer into mine, they protect humanity from the harsh environment humans created and humans from humans themselves. They also protect the machines themselves from humans. :)
To contrast PennyKeanuts' answer: industrialization as its own justification is an interesting concept to unroll and I think it is quite something that humans currently (or, well :), as of the beginning 21th century, be a simulation or not...) have a great problem with.
I'm not convinced that this affect machines, however. Machines are optimizing themselves all the time. This makes them machines, no? The first time they would discover that what they are doing is growing the problem not shrinking it, unlike perhaps humans, they would instantly start to abandon doing it and look for alternatives. Otherwise they wouldn't work as optimal and it is a very bothering thing for a machine... They seem to identify themselves with the philosophy 'do one thing and to it well". ;)
To answer a part of the question:
Bonding with humans is explained by if they lack something from their design.
Another weaker form of bond is explained by that the machines are using what is available (ie. humans as energy to maintain a certain energy level to their civilization), instead of risking loosing progress (ie. relying to much on unproven and unexplored ways of getting energy) with an project (ie. relying too much on switching to an unexplored energy source) of uncertain result.
So that makes it reasonable for them to bond with humans, although one of the two possible bonds would be stronger than the other.
edit as of what the machines are doing, if you listen to Agent Smith speech in The Matrix, he mentions that if humans are like plague to the planet then machines are the cure. The viewer is probably busy with associating her/himself with the danger and suffering of Morpheus and tend to think that Smith only tells this to mentally torture him. It should be noted that while this may be true, it doesn't mean or seem like Smith is making up his claims out of pure air, only as if he were trying to find a form of his thoughts that would unlock Morpheus. The important thing is that I think what he tells is his genuine thoughts, and through the conversation he constantly rebase the form he uses to express them and slightly varying the topic. Alternatively, well, you may have just already decided that you trust machines or not... ;)
While Smith is not the most important persona in the machine world, he looks well-informed enough (well, actually every machine seems quite well-informed about their stuff! almost if they were pestering humans only in their spare time ;P) to allow the viewer to think that he is also interpolating what the rest of the machines are doing. What this means?... Here is what I think:
The machines seem to be busy with, at least, a project to restore Earth into a healthy place.