More precisely, the 4% estimate comes from the prime number theorem, which says out of the numbers from 1 to n, about 1 / ln(n) of them will be prime.

This is actually pretty handy for cryptography, because some encryption algorithms rely on generating large random primes, and the prime number theorem guarantees you won't have to try too many random numbers to get there.