In a large enough company, managers have to do a lot to compromise the success of a company. I'm not saying managers are completely unimportant, but they're not as important as you think.
Poor management can contribute significantly to OpEx. Compared to ICs, managers have a disproportionate ability to destroy value. Of course, even that is not unlimited. It is true that companies often succeed in spite of managerial issues, but it is only to a point. Once certain lines are crossed from the legal or HR side, the potential collateral damage compared to the average value add can be massive.
With that said, I don't disagree with you that in large enough companies, managers have to do a lot to compromise the success of a company. In practice, there is often enough vertical pressure from and sideways pressures from competing fiefdoms to prevent a single rogue manager from going hog wild. And from the other end, so long as managers are adding (or able to sell the perception of adding) just enough efficiency to the overall organization to support their paycheck, it is true that the only loss is of sanity to ICs, who necessarily must become fungible to a company of that size.
But that's not the case. There are companies which are very definitively winners (in that they avoid managerial dead weight), and especially ones in technology that don't hire managers the way you describe. You often see this at quant funds (Two Sigma, HRT, etc). Of course, not everyone can or wants to work at a quant fund. But the truth is, there's no room for a ladder climbing mediocre manager at such a company, so the culture ends up being quite different.
I think the reason why you are wrong on the whole, is that you're not looking at the game that is being played. It is true that managers are busy optimizing for their own success, but if a company cannot align manager success with that of the broader company, whose fault is that, and who is wasting their resources? Leadership and investors. If you have only worked at companies with poor leadership and weak investors, it is easy to think that managers are always idiots optimizing for their own success at the expense of the company's. The truth is, there are many companies where managers get fired for just that, because the outputs are obvious and managers are looked at as intrinsic cost centers rather than profit centers. Why would I hire an ineffective layer of middle management when I could just fire all of them, hire one great leader, and have most of the team report to that great leader with strong senior ICs eventually becoming functional leads that help that single leader support the team at large?
The simple answer to avoid the problem you are raising is to not work at companies with poor leadership and investor bases. Poor management is a symptom of, not a cause of that root cause. I wonder if the reason you blame it on managers (rather than investors and leaders) is the same reason you think of managers as morons -- because you are not looking at the bigger picture.