From the moment robots were invented, they were a metaphor for slaves. Karel Capek's 1920 play R.U.R., which introduced the word "robot" staged an artificial person serf revolt. In the American context, robots have, inevitably, often stood in as an analogy for racial difference—which creates some problems. Because even when robots like Data on Star Trek plead for equality, the nuts and bolts of robot bodies plug themselves into racist tropes. Robots are programmed for racism, and while it is possible to rewrite those instructions, it takes a lot of effort.
The obvious problem with robots as a metaphor is that robots are not human. Race isn't a physical reality; there aren't any meaningful biological differences between black and white people. Robots, on the other hand, aren't even biological. They confirm that rock-bottom tenet of racism, which insists that the "races" are actually races, and that there is a fundamental difference between the person enslaved and the person doing the enslaving. In films like Ex Machina, (where robots stand in for gender difference as well as racial difference) the robot's uncanny unknowability is part of the shocking charge. The creators of the machine project humanity upon her; they treat her as if she is like them. But they cannot know what goes on within her, because she is not them.
Robot stories, though, are generally aware of the problems created when you present marginalized people as inhuman. In Bladerunner, the filmmaker's subtly and not-so-subtly suggest that some people who think they're humans may be robots—and that the human slavers are less human than the robots they've enslaved. The alienness of the robots in Ex Machina and Bladerunner is meant to be flipped; by the end of the films you're supposed to see the humans as the unknowable monsters, separated from "humanity" by their own remorseless cruelty.
There's another more subtle, and less often directly addressed problem with robot-as-slave narratives. Robots are not just different than humans; they're made by humans. And this too cosigns long-standing racial prejudices.
In his study of racist ideas, Stamped from the Beginning, Ibram X. Kendi explains that there are three approaches to racism. The first is anti-racism: the rejection of the idea that there are different human races. The second is segregation—the idea that black and white people are fundamentally different from one another. And the third is assimilation. Assimilationists believe that black and white people are different, but that over time, black people can become like white people through education or cultivation or some other method. The earliest assimilationists attributed black/white differences to climate, and believed that black people who moved to Europe or America could gradually improve as the milder climate made them less "savage" and more intelligent.
The parallels here with robot narratives are obvious. For assimilationists, white people can teach black people to be more respectable, more civilized, more human. And, in similar fashion, stories about robots almost always involve humans coaxing sentience from subhuman life. This is the case in the proto-robot parable Frankenstein, in which the monster becomes a monster because the doctor shirks the white man's burden of care for the lesser races. You can also see it in Data's desire to become human on Star Trek, as he asks his shipmates about human emotions and relationships, and tries to imitate them and fit in.
The assimilationist implications of robot slave metaphors are well illustrated in the television show Humans. Humans is set in a near future Britain in which non-sentient synths have become a standard luxury good. A scientist has created a handful of sentient synths, one of whom is captured, mind-wiped, and sold as a domestic servant. The synth Mia (played by Asian actor Gemma Chan) is named Anita by her family.
One of the central plots of the first season is the gradual re-emergence of Mia from the Anita personality. This emergence is facilitated by Mia's human owners. Matilda Hawkins (Lucy Carless), a teenage programming genius, first brings Mia to the surface by illegally hacking her brain. Laura (Katherine Parkinson), Matilda's mom, sees a flash of Mia and immediately decides that the synth is really a person. The family then works to bring Mia to full sentience.
Anita's evolution to Mia, then, is a path to consciousness facilitated and enabled by good slave owners. The Hawkins' doesn't just direct Anita to do their washing up; they treat her as one of the family and help her to transcend her initial condition. Mia, like many a fictional enslaved house servant before her, is grateful to her exploiters to an absurd degree. The father of the family, Joe (Tom Goodman-Hill) has sex with Anita as part of her 18+ adult mode functionality. Mia says that she was conscious and inside Anita the whole time—he raped her. But she never blames him for it, or even speaks a harsh word to him. Instead, she assures him that because she was present while he was raping her body, she knows that he hated himself while he was doing it, and that he was not real unfaithful in heart to his wife. Mia's primary goal, as a victim of sexual assault, is to ensure that her rapist doesn't feel bad about himself.
Assimilationism is powerfully motivated by guilt. Assimilationists like (at times) Thomas Jefferson believed that the advantages black people gained from their civilizing association with white people could make up for their subjugation. In assimilationist logic, white people are savior superheroes, swooping in to elevate benighted black people. White people make themselves holy by making black people white. When whiteness saves black people, white people are both forgiven for their crimes, and elevated above judgment. How can a creation judge its creator?
That dynamic plays itself out repeatedly in robot narratives. In Humans, the (offscreen) scientist David Elster who gave the synths consciousness is presented as an unpleasant genius—but a genius nonetheless. He sexually abused one of his synths, and is a cold and unfeeling person, yet the synths still see him as their father, as a benefactor and as a great man. In Westworld, too, the robot-creator Dr. Ford (Anthony Hopkins) is unpleasant and homicidal—but still fascinating, complex, and virtually omniscient.
You can imagine various ways in which robot stories might challenge assimilationist logic. Robots could themselves learn to create human beings, for example, scrambling who is the creation and who is the creator. Or a robot story might call into question whether humans actually created robots in the first place. I'm sure stories like this are out there somewhere, but I haven't seen them. Instead, robot stories still mostly follow assimilationist logic. As a result, even robot stories about the evils of slavery tend to present slavers as geniuses who have granted their servants the gift of humanity.