The cost of trails and approvals is not something that needs to be covered because these costs are optional (and i guess the processes can be paused arbitrarily). Profits allow you to invest in new drugs but there are other ways of financing those, like investors or loans.
The general point is, that large drug companies can leverage many things while pretending R&D _requires_ high margins.