When we imagine intelligent AIs keeping humans as pets, we tend to do so in analogous terms to how we treat animals: E.g. in sparse, constrained environments, like cages and zoos. But those environments are designed with animal level intelligence and instincts in mind. AIs will probably design habitats intended to placate human instincts. And a big part of that will be keeping us psychologically happy, which will involve providing simulated companionship.