Same as if someone were driving, if a person just jumps in front of your car while you're driving under the limit/sober/etc, you aren't at fault, so the AV should also not be at fault if it couldn't reasonably avoid the harm. You balance these things, benefit to society vs harm to society, and you come to an acceptable tradeoff.