It can work, pizza delivery has been able to be profitable for example. But they are set up from the concept to be delivery businesses, and they have that accounted for in their pricing. Doordash trying to extract profit and pay a driver and put that all on the restaurant? No that's not going to work. As a restaurant I'd refuse Doordash orders at any less than full menu price, and paid on pickup not maybe three months later. If the customer wants the convenience of delivery to their door they need to pay for it.
Middlemen are often a good idea, yes. Can you imagine if for every single item you wanted to buy you had to go to the original manufacturer? And now suddenly every manufacturer needs to also become a seller and distributor?
But they can deliver without being a middleman. E.g. they can work as contractors for the restaurant.
But now, instead, they are the ones taking the customer's orders, and hence they become the portal for the business (and thus, middlemen). Which is a bad situation for the restaurant owners.
Without middlemen every restaurant would have to be farm to table, which is a significant burden from many angles and would probably result in more shutting down than delivery services could.
Cutting out the middleman is great... but only when you run the numbers and it makes sense, not as a universal truth.