This taught me a great truth tho': the people at level N+1 compared to you in a company, are there because they have the support of people at level N+2. Unless your problem is such that you can attract the attention of people at level N+3 to it, your options are extremely limited.
As long as they're not an asshole about it, and you enjoy working with them, you should do what you can to make your manager look good, otherwise you might get another one. Once your manager moves up the ranks or joins another company, they will invite you (why wouldn't they? You make them look good.)
Generally in big companies especially, if you do well at development and promote yourself you'll become a manager regardless of managerial ability. You then get to micro manage the bad developers you mention.
But Ive never heard of someone getting promoted due to poor performance.
Performance can be very hard to measure, particularly for non-technical managers.
If he's useless as a dev and hasn't the knack for management, then he is useless (in this position).
Business wise that's the only thing that makes sense.
I used to work with an Italian company (via acquisition) that suffered from these kinds of troubles. You can't demote someone, you can't get rid of them, so they get a "sideways promotion" to something like a "project manager" or "team leader". Eventually this leads them into a managerial position. There were so many incompetent people in management at that company... their job was literally just to pass information down the chain. Meetings were hell because every project had 5 layers of managers that wanted to be involved.
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.