Issac Asimov give this AI issue a lot of thought way before it was a looming possibility. His three laws of Robotics seems like the reasonable solution. Robotics hold great opportunity for a new Industrial Revolution that will dwarf the original because factories will no longer be limited to places on the Earth. Robots don’t need to breath which is why they already have done a great job in exploring the Solar System.
The problem with Asimov’s solution is that everyone in the world would have to implement it. There’s no way to enforce that.