The main function is that it insulates upper management from any responsibility of what is going on the ground. They don't even really know. If something goes wrong you can fire some useless cog in the machine 3 links below but they still have an important title so the optics hold.
Without all these layers then upper management has to actually take responsibility for the operation of the company. Instead, they get a nice asymmetrical bet with looking like a genius if things go well but plenty of fall guys if things go bad. It mirrors the pay out of their stock options. If things go well they make a killing, if things go horribly bad they only collect their inflated salary.
The asymmetrical bet is well worth all these useless meetings to them. It is just an operating cost of the rules of this game.
In a way, it is an abuse of organizational authority. The company might need more engineers so as to reduce the burden on existing engineers. But the upper management wants to more managers to build their empire to shield themselves from any work. Thus, what gets hired is managers after managers - completely against what the company needs.
It comes from far too many layers of management and empires that constantly need to align themselves, document things, track things etc.
In my experience, every layer of manager adds an order more of red tape, meetings, and complexity.
And when they couldn't do it all, instead of removing managers, they started asking rank and file to do the same meetings and produce enormous status reports so that the layers can read it all.
Everyone is wasting time without asking the root question: Is having so many managers and management pyramids worth wasting so much time of the most productive people of the company - the people actually producing whatever you produce.