This is a common misstatement of evolution. Evolution is not directional and doesn't care whether a change is good, bad, or just completely useless. Evolution is nearly tautological: traits that result in entities being able to breed more, tend to get carried along. Traits that result in entities breeding less, tend to not get carried along.
Intelligence is a great example. It's obviously beneficial for both survival and reproduction, so should naturally be highly selected for. But in a society where higher intelligence correlates with lower reproduction, evolution will "select" for lower intelligence. Of course it's not evolution selecting for anything, but our own traits paired against our own outcomes. If it turns out to be beneficial for breeding, we could gradually even "devolve." But the notion of devolution is again somewhat nonsensical, because evolution has no direction.
So for many things I think looking for an evolutionary cause is not really meaningful. If evolution had a direction, we'd all be tardigrades.