Vietnam and foliage-killing chemicals is a hard example. (I think America was mostly in the war in fear of communism as a world power, not as much to save lives.) So I will comment on your question:
Is it the duty of a scientist to pursue truth, or knowledge? Or should they attempt to avoid the potential harm that could come from their endeavors?
You mentioned that we have a choice of whether to use the chemical or not. We also had a choice of whether or not to develop the chemical in the first place. I support scientific research (or I wouldn’t have a job right now…), but I think it’s limits should be explored. I enjoy hearing the tiniest details of biology that are being explored at my place of work, but what does it really mean? It seems to mean that we will know more, in case we can use this knowledge to do good (in the case of my research institution). Do you think there is a limit?
Maybe we are pouring millions of dollars into research that will primarily only aide the wealthier classes who can afford the treatment for a disease or cancer that perhaps primarily occurs in people over 60. I wonder if it would have been better to put that money into eradicating something like malaria, which kills all ages of people, oftentimes people who cannot afford treatment, and have not lead as high quality of lives because of that. I am trying to figure out if this situation means we currently have a limit on the amount of knowledge we need for disease A in an effort to focus the getting of knowledge on disease B. My point is that we do need and want a lot of scientific knowledge and I think it could be spent on better things than chemicals that kill foliage in wars.
So maybe it is not what is good, but constantly trying to figure out what is better?
The other problem is that we can think these things as much as we want, but in reality there are complex politics and disparities that get in the way of ever applying any answer we come up with. In light of that, why does good matter?