"why would profit-focused companies employ a bunch of people who by their own admission aren’t doing anything valuable".

The short answer: they might not be doing anything valuable, but that doesn't mean they aren't valuable.

I'm not a sociologist, so this is 'anecdotal', but I have consulted in and worked with a large number of companies during my professional 'career.

First key insight I gained is that [b]the larger the company, the greater the distance between personal action and institutional success[/b].
In a very small business, your own actions directly influence and visibly contribute to the success or failure of the company. As the company gets larger, your own actions or even complete lack their-off will for the vast majority of employees not visibly influence the needle.

In absence of this tight coupling between personal actions and company outcomes, the majority of people will be optimizing decisions in terms of the outcome for [i]themselves[/i], something their direct actions most certainly influence, rather than for some nebulous and intangible 'for the benefit of the enterprise'.

As large companies invariably have a multi-layered hierarchical structure, the lack of objective measurement in company contribution will not counterbalance the 'career-optimizing' forces, and so the average 'me'-focused person will tend to 'out-compete' a more holistic 'company-minded' individual when it comes to climbing the hierarchy.

Optimizing for personal gain does not align with company efficiency unless by accident. It often even contradicts it as 'small but efficient' solutions are the exception as their creation might benefit the one person that can claim the credit for it at some point and rise to the next level, yet burn that bridge for everyone 'coming behind' as they now are just heading a small division instead of shepherding over a large number of warm bodies and the size of the spending-budget they 'control', the universal career success measure for management.

Second key insight: [b]companies are legal entities, but don't [i]realy[/i] exist as a conscious entity.[/b]

Let me explain what I mean. As an external consultant, you never work for company X, you work for person A, the person that hires you. Same (but different), as an employee, you don't realy work for company Y, you work for the benefit of persons B and C, people that got you onto their team to improve their situation.

Combined, both of these insights lead to the realization that a vast number of people do not work because they create by their work actions, their 'job', a focused benefit to 'the company', the 'customers/clients' or 'society at large', all of which are typical personal 'value' related vectors.
They work because they are foot-soldiers that provide 'value' in the managerial hierarchy wars, which is something most people will not recognize as 'value' but as 'bullshit'.

A third key realization(I promise, I'll keep it at that), and the one that answers [b]'but why are these inefficient behemoths not put to rest by highly efficient competitors[/b], is that a lot of people tend to misinterpret Darwinian dynamics, a common popular conceptual model in thinking about 'markets' and 'efficiencies'.
Popular interpretation that of the 'survival of the fittest'. They imagine animals (enterprises and businesses in this context), to be in an eternal struggle (red in tooth and claw), resulting in the leanest and meanest, the most efficient providing the best 'fit', rising to the top. The invisible hand of the market will create optimal, highly efficient companies in each sector. Unfortunately this model and the interpretation there-off are deceiving. Rather than selecting for the best, a Darwinian dynamic 'just' selects for a sufficient fit to a niche, and only works by weeding out the bottom, those that fail to find a place in any niche at all. In 'static' systems running for a sufficiently long time, promoting the top or weeding out the bottom can lead to the same outcome. In 'dynamic' systems, where 'niches' change over time, both mechanisms can have very different outcomes. Theoretically speaking, top selection tends to efficient but 'over-fitted' solutions, bottom removal does not favor efficiency but resilience, doing 'good-enough' to survive under very many circumstances.
Companies that truly 'solve' a problem (something that is definitely on the 'value' scale when people think about 'is my job meaningful'), either eliminate the very basis of their existence by eradicating the 'problem' they solve. It's hard to think of such things or companies, because both they and their reason for 'existence' have disappeared. A more stable solution in terms of company (and thus job) existence must have an ongoing number of cases to 'solve', ideally (in terms of stability) by having the 'solution' create it's own demand for more 'solution', a dependency. People think we as a society weed these out, because they are culturally immediately conditioned to think of 'heroin' or 'illegal substances' as the example of the archetype of of the dependency inducing concept. Thing is that our whole socio-economic market system is based on creating and sustaining ongoing dependency.So once again, people seeing that the company they work for doesn't solve but even plays a role in creating the problems it pretends to solve, again find their job 'meaningless' at best.

Sorry for the long post.