I have published three books. Two are out of print and avaiable for free on my personal web site. Also on my coauthor’s site. The third is still in print, but when it goes out of print, it will also go there. They are highly technical books and anyone who is interested can easily find out where to look.
As for research papers, the story is this. They go already typeset by the author to an unpaid editor of a journal who sends it to one or more unpaid referees and then, if they are accepted, they are put into print and posted behind a paywall. The journals are sold back to us at an enormous price. $4000 for annual subscriptions are common.
On the other hand, I act as technical editor for an online journal that is free. Since the publishers pay nothing for all the editorial and refereeing work, we have simply taken the next step and saved the middle man. A university does allow us the use of their computers for posting the journal, but these days srorage is so cheap that even that cost is negligeable.