The machines tried at first to make humans always happy in the virtual world they've created. They did that not out of care for humans, but in order that they could peacefully harvest energy from the oblivious humans' bodies.
As I remember it, it didn't go well in terms of production. So, the machines replicated the real not-always-so-happy world instead.
I'm not trying to suggest anything btw.
Or, am I?