Do what works for your world
As far as I can find, the rules don't say much (if anything) about the prevalence of the ability to either read or write in the world. You should instead do whatever makes sense for your world and keep this in mind when designing it.
I was able to find various quotes from the DMG, PHB, and MM that are about languages, but none of these feel especially important or insightful to me for the question you've posed:
By virtue of your race, your character can speak, read, and write certain languages.
When fleshing out your world, you can create new languages and dialects to reflect its unique geography and history. You can replace the default languages presented in the Player's Handbook with new ones, or split languages up into several different dialects.
In some worlds, regional differences might be much more important than racial ones. Perhaps all the dwarves, elves, and humans who live in one kingdom speak a common language, which is completely different from that spoken in the neighboring kingdom. This might make communication (and diplomacy) between two kingdoms significantly more difficult.
Widely used languages might have ancient versions, or there might be completely different ancient tongues that adventurers find written in tombs and ruins. Such languages can add an element of mystery to inscriptions and tomes that characters encounter.
You might invent additional secret languages, besides Druidic and thieves' cant, that allow members of certain organizations or political affiliations to communicate. You could even decide that each alignment has its own language, which might be more of an argot used primarily to discuss philosophical concepts.
In a region where one race has subjugated another, the language of the conquerors can become a mark of social status. Similarly, reading and writing might be restricted by law to the upper classes of a society.
Whether a monster can speak a language has no bearing on its challenge rating.
A monster can master as many spoken languages as you want, although few monsters know more than one or two, and many monsters (beasts in particular) have no spoken language whatsoever. A monster that lacks the ability to speak might still understand a language.
DMG page 279
The languages that a monster can speak are listed in alphabetical order. Sometimes a monster can understand a language but can't speak it, and this is noted in its entry. A "—" indicates that a creature neither speaks nor understands any language.
For me, the quote that best exemplifies the ability to make the world your own is this:
Similarly, reading and writing might be restricted by law to the upper classes of a society.
Who is taught how to read and write, and how prevalent such a skill is, is up to the world of the GM. This is similar to how the GM can design how fantastical, how magical, how gritty, and so on, their world is. Similarly, you can design how literate your world is. When designing worlds, you should consider things like spell scrolls and wizard's spellbooks and other similar complications that might come up when having these skills be scarce.
Personally, I have found assuming everybody to be literate to be easiest on myself. I don't have a fantastic understanding of the real-life experience of medieval times, I instead have a fantastic understanding of the real-life experience of modern, 1st-world times. I know a lot more about how interactions and correspondences work in a literate world than in a predominantly illiterate one and can use what I do know in designing my world. The alternatives, for me, would either be outright guessing, or extreme amounts of research, and (usually) neither appeals to me and so my worlds have high levels of literacy.