With quantum computer that can easily fits inside our can drinks and machine learning algorithm so advanced that we can easily fool all animals especially ourselves to tell the difference between what's real and what's illusion. In the future we can hug and pat holographic projections using invisible pressure wave in the form of ultrasonic transducer, or play a game of fetch with a mechanical canine. No longer do owners have to suffer the loss of their beloved pet, hopes for those with asthma and allergy problems and no need to clean up their mess. However I could not see why many still prefers keeping live pet in the future?
This is like asking why a book is better than an ebook, or why a letter is better than an email. No matter how convenient or easy or clean something is, there's just something about knowing it's real. People keep pets to pet, yes, but ask anyone with a pet, even people who just have a fish, and each and every one will tell you that their pet is a person too. It has a personality. It has likes and dislikes and quirks that make it unique. Yes, a robot could be programmed to have a little randomness, to develop x number of quirks, to develop tastes. You could take all the good things about pets and make them real in a robot, and you could get rid of all the bad things, but really, what makes pets special is that they're real. A stuffed animal is still soft, it will still snuggle you, you can heat it up and it will be warm, but it will never be truly real. That's the difference. It doesn't matter how good an imitation something is, if you changed anything at all, even things that are clearly for the better, it's not real anymore. There's a reason people don't write books in which nothing bad happens, and why there are no movies where nothing goes wrong: life is about the moments when something sucks, when it breaks, when everything goes wrong, when plans go awry, and just basically the worst moments because those are the ones that make the person, and those are the ones that make the pet.
That being said, having a real pet is definitely an endeavor. It's hard, it's dirty, and it's expensive. It takes time and love and forgiveness, things that not everyone has. I could very well see how the general populace might end up with robot pets. Easier, cheaper, safer... it's basically fast-food. You know it's not real, but it's quick and easy and it'll do. People still want to sit down and eat real food, though, and the same would be true with real pets. The wealthy, who had the time and money, would have real animals, and they would probably flaunt the fact whenever they had the chance. Real pets would become a status symbol, like fur coats, and just like fur coats, faux pets would do their best to imitate the real thing, but they would never replace knowing that what you have is really real.
The tactile feedback of touching another living thing is far more complicated than it looks at first. Living things respond to your presence. They also respond to how they perceive your emotions. Many of these responses are very rapid, within a few hundred milliseconds. It can be very difficult to reproduce these accurately, especially because they depend on how you feel at the time, so you cannot pre-record them.
However, this does point to an interesting choice your world can make. If, in the midst of a technological revolution, they have to choose between whether they raise their children to interface with living things or machines, the children may never learn to desire that living feedback. In fact, it could even become uncomfortable (because it is terribly hard to predict in advance how it will go). As a result, a technologically advanced society may loose touch enough that they may be totally comfortable with an anamatronic device.
Because they read the scientific news that became available in 2016, and realized that cat-related toxoplasmosis results in more "shades of gray" (proclivity to BDSM), and don't want to lose that.
Because some people always have irrational affinity for what's "natural" and rejection of what's "artificial". in 2016, there are people who snub eBooks in favor of dead tree books. Who buy hand-crafted things of questionable quality just because they are "artisanal".
Because there's a psychosomatic (or may be real?) difference in levels of satisfaction of petting a live animal vs. fake one, even if the lab tests show no difference in objective tactile and audio experience - leaving aside that the latter is nearly impossible to achieve in the first place.
People like to listen to live music instead of to hi-fidelity record, even though the latter is (1) cheaper, (2) can be better quality because you have better performer recorded and (3) you don't have downsides and inconviniences of having to go to a concert.
It is simple, THE COST!
Because in future too, adapting such technologies would be expensive for many.
Even if we assume that poverty on Earth would be abolished completely in future, It is still difficult to assume that each and every one would be economically balanced. Despite availability of such technologies, their cost may divert humans to use the 'real' pets.
Also, if we are to establish civilizations on other planets, migrating technologies from Earth to those planets or simply creating technologies on those planets too would be highly costly. It will be easier, comfortable and far cheaper to migrate the real pets to other planets.
If we even think more about the future...
The future criminals may use your virtual pets to kill, rob or kidnap you simply by hacking or manipulating the code and/or wirings. But hypnotizing real pets is very difficult if not impossible.
Taking a slightly different psychological approach...
Have you considered the Uncanny Valley?
Many people find animatronics to be kind of creepy. Oddly they can be even more unsettled when they're more realistic.
You may remember The Furby from the late 90's:
It was more or less an early artificial pet, but notice also that it appears almost deliberately artificial looking, bearing little to no resemblance to any actual person or animal, but some people still found them creepy.
Now compare the Furby with the Genpet1:
I'm guessing that you can see where I'm going with this, but to state the obvious... a lot of people were really disturbed by the Genpet concept. The more "real", life like, and (perhaps most disturbing) humanoid an artificial pet becomes the more some people will be upset by them.
Now there are obvious caveats and edge cases, The Furby did experience wild popularity albeit short lived popularity, but the uncanny valley will likely be a huge design consideration for future artificial pets, and perhaps a reason that some people will never truly accept them.
Because the pet can love you back.
That is certainly true in the case of animals of relatively high intelligence like cats and dogs. For less intelligent creatures like fish it might be more debatable whether it is capable of love, but even then there is something like a relationship between two living things. You can make a pet happy.
The near perfect technological reproduction of the physical sensations of having a pet may satisfy some, but it will not allow the human to give. For much the same reasons, humans will mostly continue to seek the company of other humans, however realistic androids get.
However if science advances to the level where robot pets can be made as sentient as the animals they imitate, things might be different. But how would we know? The manufacturers might claim that the robo-dog truly felt love for you, and its behaviour might be programmed to resemble the behaviour of a loving dog in every way, but I think people would still doubt. The only way that I would be convinced that a robot had been made as self-aware as an animal would be if I had already been convinced that a robot could be made as self-aware as a human. (This would happen by the robots passing the Turing Test or similar. Basically, they'd tell us that they were conscious and we'd believe them for the same reasons that we believe each other to be conscious.) Thus, I suggest, sentient robot pets will follow, not precede, the development of sapient computers, despite the creation of animal-level artificial intelligence being an easier task than the creation of human-level intelligence.
Life Lessons All those inconveniences of having a pet that you can neatly program out--well, they teach children things, and for adults, owning a dog is like training for having kids. (It's not the same, but it's a start.) People want the experience and they want the inconvenience. If you've cleaned up dog puke at 3 a.m., you have to factor your dog into the expense for every vacation, and you've cleaned up dog poop with those little bags, then kids are the next step up. By having a pet, you'll know that some things are out of your control, you have to clean up some gross things, and that your life has to be adjusted for the pet. Having a programmable death installed, is not the same as real death. The death of a pet is often the first way that children learn to deal with death.
Your pet chews something up? Wipe that part of the program. You never have to find a way to change your life to accommodate that tendency, or teach the animal. There's something to be said for that experience.
You may as well ask, why adopt children instead of programmable people who grow--there's no off switch on a kid, they pee and poop and make dinner inconvenient.
It's boring and mass produced. Because a mass production of pets means that they won't have individual personalities, and if they are programmed, they will all respond the same way. You are talking about algorithms as though that will mean that the electric pets have the same sort of responses animals do--but there's a lot of things that animals do that we don't like--and that's part of what makes them interesting. We have thousands of YouTube videos of pets which do something or learn something unexpected--like the one which tries to attack the windshield wipers, or coming home to find your kitchen ruined, with two dogs telling on the one who did it.
Expensive Also, it seems like that would be massively expensive. That's a pretty good reason not to get one.
Programmed love is not the same. Getting love from something that's programmed to love you is not the same as getting love from something that decides to love you.
Loss makes every day count.
"You don't know what you've got 'till it's gone"
If something were to last forever, then there's no particular drive to enjoy its presence right now. That, in turn, means you'll never truly enjoy something in the way that you would if it were to cease existing at some unknown point.
To live - truly live - is to love, to feel, and to enjoy the moment whilst it lasts, because we know it won't last forever. This applies to anything that's alive - pets or indeed family members too. Cherish those fewer special moments rather than drown in the endless ones; something that would otherwise be special becomes routine and therefore ordinary.