I recommend reading the Robots series from Isaac Asimov. It deals with this very questions and paradoxes and it's a scifi classic.