"How in the world when paying for prescription coverage can their price wind up being more expensive than the price with a free discount card?"

The insurance companies simply profit by making copays higher - sometimes much higher - than the actual cost of the drugs.

It's worth checking multiple discount cards for every prescription. The pharmacies' own discount programs are often worse than some of the others. Pharmacies have apparently started to offer their own programs in hopes that you won't bother to check GoodRx et al. and they can charge you more.

In addition to NeedyMeds mentioned in the article, it's worth checking the other discount cards listed at https://www.healthline.com/health/best-prescription-discounts.

For my most recent very expensive prescription, Optum Perks offered a better price than GoodRx.