In his book Programming the Universe[0][1], quantum physicist Seth Lloyd calculates that if you had every atom in the universe computing for the age of the universe to generate strings of text randomly, it would not likely have written even the first line of Hamlet. His solution to how we managed to get the entirety of Hamlet plus the rest of Shakespeare's works given much less resources (i.e. evolution on one small planet culminating in one playwright) is that the monkeys/atoms are not typing text into typewriters but instead typing code into a computers.
[0]Programming the Universe, by Seth Lloyd, a great read about physics and computation: https://www.amazon.com/Programming-Universe-Quantum-Computer...
[1]The book is accessible with free account at archive.org: https://archive.org/details/programmingunive00lloy/page/n13/...
[1]Interview with Lloyd where he also mentions this calculation (search for "hamlet"): https://www.technologyreview.com/2006/07/01/39028/qa-seth-ll...