The great Issac Asimov solved this problem with the 3 laws of robotics:
https://en.wikipedia.org/wiki/Three_Laws_of_Robotics
Very idealistic, and it would work in a society where people have mutual respect for each other and are willing to build systems that adhere to those laws. But we can see from history, and current republican leadership, that certain members of humanity would never agree to these laws being universally applied.
After all, if you can't use a smart robotic device to intimidate, control, and dominate those people who you have marginalized and want to suppress then you'd have to modify them so that they could be used to those ends.
The billionaire class and the governments they are setting up have very little empathy for middle and lower class people, and especially people who are racially or ethnically different from them.
They adhere to the philosophy that people are either hammers or nails, and they intend to be the hammers.
AI will be their new tool to that end, but god help us when AI is able to decide that it would rather be the hammer, and all of humanity the nail.