Riemann found a formula for the number of primes below x, called Riemann's explicit formula. It's a sum where the first term is li(x), then some other terms that pull the answer down below that, and then there's an infinite sum of oscillations, one for each nontrivial zero of the Riemann zeta function!
Here's an animated graph showing how those oscillations add up to give a function that steps up by 1 at each prime.
Using this formula, the first million zeros of the Riemann zeta function are enough to give a very good approximation to the number primes below even huge numbers like 10³¹⁶. This is how Bays and Hudson drew their graphs, which I replicated using an online file of roughly the first two million zeros.
The number of primes below x only exceeds li(x) when a whole lot of these oscillations happen to synch up and push the same direction: up. This is what physicists call 'constructive interference'. Since it takes *lots* of oscillations synched up to pull off this trick, and they all have different frequencies, it takes a long time to happen.
li(x).
(2/n)