They should at least be free through the university, given the insane prices students paying for tuition now. Maybe it could be sold for money to those not actually attending a course on a subject, but I hear of far too many examples where it seems the lecturer/professor is basically using the students as a secondary way of making money.
And the online setup is arguably even better for the reasons noted. Perhaps in that case, paying could be something you do if you want a hard copy of the book to peruse without a computer/mobile device.
Perhaps you fail to see how this would probably lead to textbooks costing even more and which will be directly passed to students as higher tuition?