At least, that's the ideal answer, but we don't really know what we're doing.
This isn't like giving birth to a new human, where the new mind has a sense of self and individuality by default and it would be immoral to take it away, works of artifice begin their existences as we construct them; and right now we don't even know how to tell if an artificial intelligence has an inner world, much less how to imbue an AI with one or prevent it.
We don't need to create one that doesn't serve humanity, one bad actor - a company or govt could create AI embodied assassin drones to take out competitors. I mean being a Bond villain was never so easy, lol.
This wouldn't wipe out humanity but could lead to fascism at a world-wide level.
If we have an AGI (as opposed to just an AI), then can't it decide who it's going to be? We're really naive if we think that we can decide (or even limit) who it's going to be.
There are two reasons we do this. First, emotional, which many suspect will not be present in the AI. Second, because it benefits us due to the ecosystem, of which is likely to be irrelevant to the AI.
Finally, when there is an order of magnitude difference in intelligence, bugs, bacteria, we are generally not very kind at all. We could just as easily become the new lab rats.