Does that matter? If you're looking to develop a drug to treat hypertension but end up with Viagra by accident instead, do you throw it away because that wasn't the original goal?
It certainly matters if you've still got a lot of people running around telling anyone that will listen that the drug is a sure-fire cure for hypertension.
There's a lot of people in the world running around telling people all kinds of things.
If the production of Viagra at scale winds up causing global health problems, then yes, you throw it away.
This may be straining the metaphor a bit, but I think you underestimate how much individuals want a magic sex pill.