The trial costs are small compared to R&D costs, but that's only because R&D costs are very large. So it's millions of dollars compared to billions of dollars.
But generics don't have R&D costs, they already exist and are out of patent. Which correspondingly makes them much less profitable -- that's the whole point -- and then "millions of dollars" becomes a significant cost.
Moreover, it's a free rider problem, because once you pay for it for a generic drug, anyone can make it, but they didn't have to pay the millions of dollars for the trials so now they can undercut your price.
As a result everybody sits around waiting for somebody else to spend several million dollars for a trial instead of doing it themselves, which means that nobody does it.
https://www.jhsph.edu/news/news-releases/2018/cost-of-clinic... https://www.outsourcing-pharma.com/Article/2018/09/26/Clinic...