The writing simply has to be very high quality. Reading in games obviously is not entirely unpopular, see Disco Elysium, but then again that eventually got very good voice acting to read it all out, which helps a lot
Planescape: Torment stands out as one game where I enjoyed the walls of text. While it was a lot of text, the text was relevant to the plot rather than going off world building as in Baldur's Gate 1/2's pile of books
I have exactly same experience. I finished PS:T week ago and it was really good and interesting reading.