Societies are complex, and pretty well all laws have unintended effects (though, often, they’re not problematic and we’re happy to live with them).
I disagree that the result would be an instinctive aversion to legislating. I take the point that that would have avoided laws banning discrimination on the basis of credit scores, but the same instinct would tend to avoid laws banning discrimiantion on the basis of race (which we all agree, don’t we, are good laws that we are right to have?).
I think we need to do two things. First, think about laws before we enact them, and test them against the evidence. Accept that the outcome of the law that you are hoping for will not be the only outcome, and put a bit of thought into identifying and assessing other likely outcomes. Laws should be based on well-thought out and well-tested policy, in other words.
Secondly, accept that laws do have unintended outcomes and this is unavoidable. So, as Senegoid suggests, part of any robust legislative process has to be review of the operation of the law once implemented, followed by repeal or modification as appropriate.
And if you need to repeal or modify the law, don’t regard that as necessarily a failure. You framed your policy, you implemented it, you tested it and you have learned something. If the law had disastrous outcomes that really ought to have been foreseen yes, that’s a failure. But if the unintended outcomes were the result of changing circumstances, or factors that couldn’t reasonably have been identified or assessed when the policy was first made, then you have learned something useful.
But the real problem here is, well, democracy. One of the main reasons why laws have consequences which are not those desired is that the laws are popular. Get-tough-on-crime laws, for example, are popular and get passed for that reason even though we know that, mostly, they are not very effective to reduce crime rates and the principal outcome is to increase taxes to pay for more prison accommodation. But the problem isn’t that nobody foresees this; it’s widely recognised. So while these consequences are perhaps unintended, they’re not unexpected. And that problem is not down to poor policy preparation or a failure to review the legislation once implemented.