I think when it comes to paying for journal publications, the cost has to do with the peer review and critical analysis process. At least, that's a way to try to "justify" paying for publicly-funded papers. You cannot cite printing/mailing cost because then their online version should be free or very nominally priced (running the servers/storage should be fairly cheap these days).
So what I mean by peer review/critical analysis is that journals receive hundreds of potential articles every month, maybe thousands. They need a team of people there to critically analyze the papers on their merits and find methodological issues that could bias the results or lead to false conclusions. We would assume the authors and their respective institutions would have already done this, and we know of cases of academic fraud which have escaped detection for years, but you would expect the more you pay for an article (or the more "prestigious" the journal) the more time and effort they would have spent vetting it.
Now I have no idea if there is any correlation between the quality of articles, scientific importance or methodological rigor employed in them and the journal in which it appears (class "A", "B" or "C"-level, etc). All I know is some labs go absolutely crazy if they get published in Nature or British Medical Journal, but then there are other less prestigious journals that will publish them, and then bottom of the heap ones. Would they differ in the importance or significance of the article? Does it make a difference to the amount of research money the lab gets? Publish or Perish?
There is definitely a model there for reward and I think these journals fit in that, but I'm not entirely sure if the people employed by these various journals warrant being paid or are needed to sort and categorize and rate the articles that are being written, and if we are paying for that service in a way. Imagine a free-for-all science hub where anyone can publish... Usually scientists and researchers can determine themselves the quality of the article or lab because of previous publication history, number of other articles that reference it (sort of the "hyperlink" score), etc.
I'm not in a University setting anymore digging up journals and yes I did access articles from a few journals using my professor's account (he subscribed to the printed journal and gave out access to some of his students to access it online)... but these were like $250 a year subscriptions, were very specialized, and impossible for students to afford who were trying to write their own papers or look up basic information. And the teachers made photocopies of everything, I'm sure they didn't pay the publisher a cent and this was in an academic institution! But I can see why you may need to have a publisher, why they need to make money, and what possible service they may provide to the scientific community. If things go absolutely "free" online it may make it more difficult to filter through the crap and bias and insignificant stuff to find the golden quality gems, unless the online system is designed to allow feedback and ratings and peer review to be tagged along with each article (and trusted credentialing).