If you think of the police as the executive arm of the judiciary, then you can understand why they would want to give them immunity from accountability for their actions. The courts have ruled that the police are no responsibility to protect the public which only leaves their ability to enforce some laws as their responsibility.
Qualified immunity dates back about 60 years as far as I can tell and is a complete creation solely of the courts.