Perverse is often used to describe something that has the opposite of the intended effect.
From Dictionary.com, the first definition:
per·verse [per-vurs] (adjective) willfully determined or disposed to
go counter to what is expected or desired; contrary.
The same link goes into the origin of the word:
1325–75; Middle English < Latin perversus facing the wrong way,
askew, orig. past participle of pervertere. See pervert
While the words perversion and pervert are often tied to topics of sexual deviancy, its underlying meaning can be more directly associated with the word misguided (which is indicated as a synonym of perverted).
So you can say someone is misguided if they think continually scratching an itch would be beneficial. You would say that scratching has the perverse effect of ultimately causing harm.
Examples of perverse being used this way are not hard to find.
Here is one titled "The Affordable Care Act's Perverse Incentives" which describes the counterintuitive effects of a law this way (in it's second paragraph):
While recognizing the importance of these improvements, this Essay
focuses on how the ACA will also create perverse incentives harming
low- and moderate-income workers. This Essay explains how the ACA will
impose effective taxes with respect to low- and moderate-income
workers, thereby reducing these workers’ employment opportunities and
creating a number of other economic and social harms.
Here is another, "Perverse Habits: The G8 and Subsidies That Harm Forests and Economies" It begins:
In 1998 the leaders of the Group of Eight (Japan, France, the United
States, Great Britain, Germany, Italy, Canada and Russia) committed to
actions that would help protect the world’s forests. Some G8 members,
however, continue to provide large and perverse subsidies to forest
products industries promoting programs that undermine forest
protection and accelerate forest loss.
More examples are given in the section titled "Perverse Results" in the Wikipedia article on Unintended consequences.
The term perverse incentive is described as
an incentive that has an unintended and undesirable result which is
contrary to the interests of the incentive makers.
Interestingly, the links on unintended consequences and perverse incentive lead to Cobra Effect, which has a fascinating origin:
The cobra effect occurs when an attempted solution to a problem
actually makes the problem worse.
I won't quote the origin, which is worth reading at that link, but it has to do with how incentivizing the killing of cobras to reduce their abundance eventually led to the breading of them, which led to other unintended consequences.