Many pose the question, “Does the end justify the means?” without examining the same question, but switched around.
Does doing good deeds justify a bad outcome? Yes. It is rare when we know for a fact that doing evil will result in a good outcome, so why try to do wrong to achieve a good end? Doing good (feeding a starving child) is justified despite an occasion where the child may get sick from eating it.
But back to the more common question, “Does the end justify the means?” Should we avoid giving a hungry kid some food, knowing he may get sick? No. We don’t know he will get sick.