Welcome to Ultron. Humans are a threat to life if you take life as a whole. The only life we’re really necessary for is domesticated animals.
Humans are bad enough at the Trolley problem. I don’t expect AI to be any better, especially if you add a track with the environment and other lifeforms as potential casualties of whatever choice it makes.