The original laws of this country did not permit lawsuits against government employees acting in an official capacity. After the Civil War, the Civil Right Act of 1871 was passed allowing citizens and residents to sue government officials for civil rights violations suffered under color of law. The qualified immunity doctrine was created by the courts after that to shield public officials from nuisance suits for discretionary actions (generally meaning bureaucratic actions) by people angry over actions that went against them (i.e., for denials of licenses, judgments, etc.).
Unfortunately, due to the volume of nuisance suits, this doctrine got stronger and stronger over time. At some point, the courts began applying this strengthened doctrine intended for bureaucratic actions to police actions.
But why shouldn't all people be protected from nuisance suits over reasonable mistakes?
So if I grab someone off the street and handcuff them we can be almost 100% sure I'm committing a crime. If the police do the same thing we can be almost 100% sure they are not committing a crime.
Exceptions happen in both cases but it's not unreasonable (which isn't to say it's correct) to take make laws that take that into account.