Like it's stated above, the theorem resembles that of the infinite monkey theorem.
The theorem is purely a proposition than an unlimited number of monkeys can “almost surely” produce a specific text such as Macbeth or even the entire works of Shakespeare, provided that they are given sufficient typewriters and time.
The probability of a complete universe full of monkeys typing an entire complete work of Shakespeare such as Macbeth/Hamlet is so tiny that the chance of it happening is extremely low (time taken to perform the feat should be longer than the age of the universe). But do remember that the mention is “extremely low” which technically, isn’t a zero.
There is a direct and straightforward proof of this theorem. Remember that if two events are independent, the probability of occurrence of both the events is equal to the product of the probabilities of each event happening independently. A simple example:
Chance of rain in place A on a specific day= 0.5.
Chance of rain in place B on a specific day= 0.4
Chances of rain happening on the same day in BOTH places= 0.5 x 0.4= 0.20.
Hope you get the point. Now let’s get back to the theorem.
Imagine that a typewriter has 50 keys. The word that you have to type is “SLEEPY.” According to this theorem, we’ll have to press the typewriter keys randomly and at the same time, generate the required word. We have ample time and resources on our hand. So the only limitation is patience, but that’s not the point. Our point is to prove that it CAN be done. If the typewriter keys are pressed independently and randomly, each key has an equal chance of being pressed.
So, the chance of the first letter “S” getting typed= 1/50.
Chance of the 2nd letter “L” getting typed= 1/50.
The same is true for other letters in a word SLEEPY. Therefore, the chance of getting the word right is-
(1/50) × (1/50) × (1/50) × (1/50) × (1/50) × (1/50) = (1/50)6 = 1/15 625 000 000.
Very very very small but it is NOT zero. Therefore it is very possible.
This is basically just a theorem IMO. It's almost impossible to implement test this concept in the real world and expect a correct result.
Source- The Infinite Monkey Theorem