A middle-man can say "We will supply your cleaning in several cities no matter your office size."
So a company pays a higher cost - but only has to deal with one contract, which saves them effort elsewhere.
It's the same as taxi companies. It would be cheaper for you to call a small firm with lower overheads, but you're happy to pay a premium for convenience.
They have fewer contracts at any given time but also the contracts can last longer.
If I directly hire people to clean an office, when they don't want to do it anymore I need to find other people to do it. Selecting people, negotiating, getting payments set up with accounting etc. Its a distraction from more important stuff so I want to do this as rarely as possible.
If I hire a company/agency/middleman they can replace people without me having to even be aware its happening. At the point "keep the office clean" is essentially solved. Its possible I will never need to think about office cleaning ever again and I can get on with running my business.
When people plant themselves in the middle, they essentially sell themselves as being necessary. Are they necessary? It depends .. but usually not.
I suspect it was cost. The middle men would just under bid and then under deliver.
There are a lot of activities for which sub-contracting makes sense, particularly when there are possible economies of scale, but when the activity is merely (or largely) labour, there are only four possible overall outcomes:
1) the actual workers are paid less than what would be fair
2) the service is inferior to what was expected/agreed upon
3) the service costs more (the middlemen somehow have to take their part)
4) the contractor or sub-contractor has made wrong estimation of the costs and before or later they close or go bankrupt