Take for example a poor developer who keeps breaking things. It can actually be difficult to get rid of someone. So the company instead makes him a low level manager (no longer directly touching code).
Yes! he comes up with stupid ideas etc, but, his team know he is wrong so they just work around the stupidity.
In a couple of years of poor management from this junior manager (who team keeps working through). Upper management (who forgot how bad a developer he was) think GOD! he has done a good job; his team get things done. Lets promote him.
Bad manager is now in a higher position again.