As I mentioned in the comments, one particularly striking example of serendipity is the connection between the theories of L-functions and random matrices.

The IAS hosted a conference recently, commemorating 50 years since the discovery of this connection, and I highly recommend the history talks given by Montgomery, Sarnak, and Keating.

The story, paraphrased a bit, goes as follows. In the early 70s, Hugh Montgomery (then a graduate student of Davenport), motivated by an approach to solving the Siegel zero problem, formulated what is now called Montgomery's pair correlation conjecture for the zeroes of $\zeta(s)$. By Montgomery's own telling, when you proved something "new" in analytic number theory at the time, the first thing you did was ask Atle Selberg whether he had already proved this and left it unpublished in a drawer somewhere. So, Montgomery visited Selberg at the IAS to talk to him about it.

It turned out that Selberg had not, in fact, already done what Montgomery showed him. After his conversation with Selberg, Sarvadaman Chowla took Montgomery to tea-time, and introduced him to Freeman Dyson (much to Montgomery's chagrin: Dyson was already a famous physicist by then, and Montgomery "didn't want to bother him").

Dyson asked Montgomery what he was working on, and Montgomery said something to the effect of "I think that the distribution function of spacings between zeroes of the Riemann zeta function is $1 - (\frac{\sin \pi u}{\pi u})^2$...", to which Dyson reportedly replied without missing a beat something to the effect of "... that's the pair correlation of the eigenvalues of random matrices from the GUE ensemble". Both these quotes are not precise -- I don't think anyone who was there actually remembers precisely what was said -- but it's not far off. I suggest this link and page 5 of this paper for some popular science accounts of the conversation. This article from the IAS, shared by Stopple in the comments is also very nice.

(In case you are wondering why Dyson knew this: random matrix theory started out as an approach to model energy states in nuclei of heavy atoms, and physicists -- including Dyson himself -- developed much of the early theory).

In terms of the mathematics, assume RH and define

$$F(\alpha) = \frac{1}{N(T)} \sum_{\gamma,\gamma'\leqslant T} T^{i\alpha (\gamma - \gamma')} w(\gamma - \gamma'),$$

where the sum runs over ordinates $\gamma,\gamma'$ of nontrivial zeroes of $\zeta(s)$ in the interval $[0,T]$, $w(t) = \frac{4}{4+t^2}$ is an explicit weight function that you should think of as damping the effects of large spacings $\gamma - \gamma'$, and
$$N(T) = \sum_{\gamma \leqslant T} 1,$$
is the counting function of the zeroes. $F$ should be thought of as the normalized Fourier transform of the distribution of $\gamma - \gamma'$.

Montgomery proved that
$$ F(\alpha) = |\alpha| + o_\epsilon(1),$$
uniformly for $\epsilon \leqslant |\alpha| \leqslant 1 - \epsilon$, (there's some lower-order terms I am neglecting for the sake of exposition), and conjectured based on heuristics involving prime $k$-tuples that
$$F(\alpha) = 1 + o_\delta(1),$$
uniformly for $1 \leqslant \alpha \leqslant 1 + \delta$ and any $\delta > 0$.

If one assumes Montgomery's conjecture and applies Fourier inversion, then one obtains that
$$ \frac{1}{N(T)} \sum_{\substack{\gamma,\gamma' \leqslant T\\0 < \frac{\gamma - \gamma'}{2\pi/\log T} \leqslant \beta}} 1 \sim \int_0^\beta\bigg(1 - (\tfrac{\sin \pi u}{\pi u})^2\bigg) du, $$
which hopefully clarifies the story above. (Note that one divides $\gamma - \gamma'$ by $\frac{2\pi}{\log T}$ as this is the mean spacing between zeroes for $\zeta$, which follows from $N(T) \sim \frac{1}{2\pi}T \log T$.)

If you replace the zeroes of $\zeta$ with eigenvalues of GUE matrices in the large dimension limit, then an analogue of the above was well-known. In fact, the eigenvalues of GUE matrices are an example a determinantal process, and their $n$-level correlations were all well-understood by physicists. Montgomery speculates on the basis of this that the distribution of zeroes on the critical line is the same as that of GUE matrices, which is usually called the "GUE hypothesis". This speculation has a lot of supporting numerical evidence, due to the work of Andrew Odlyzko, who used computers at Bell Labs for his computations; for this reason the GUE hypothesis is sometimes called the Montgomery--Odlyzko law.

Hejhal computed the triple correlation and Rudnick--Sarnak computed the $n$-level correlations (with as large Fourier support as current methods allow) for $\zeta(s)$ and showed they agree with the GUE hypothesis. Rudnick and Sarnak actually computed $n$-level correlations for all high zeroes of principal automorphic $L$-functions, and showed agreement with GUE.

This connection has proven to be fruitful in more ways than indicated above. The two most prominent examples are:

- The Katz--Sarnak density conjectures. Motivated by their work on function field analogues, Katz and Sarnak conjectured that the low-lying distribution of zeroes (i.e., the zeroes with imaginary ordinate $\ll \frac{1}{\log \mathfrak{q}_f}$ where $\mathfrak{q}_f$ is the conductor of $L(s,f)$ and $f \in \mathcal{F}$ runs over some automorphic "family") of $L$-functions depends only on a symmetry type associated with $\mathcal{F}$, which can be one of unitary, symplectic, or (odd/even) orthogonal and matches the corresponding statistic for random matrix ensembles. One can view the above as a special case of these conjectures since $t \mapsto \zeta(1/2 + it)$ can be thought of a continuous family of $L$-functions parametrized by $t$, with unitary symmetry type. A seminal result on these conjectures is the work of Iwaniec--Luo--Sarnak, where these conjectures were proved for many families and bandlimited functions with small enough Fourier support.
- The Keating--Snaith moment conjectures. Since the characteristic polynomial of a matrix vanishes at its eigenvalues, while $\zeta(s)$ vanishes (obviously...) at its zeroes, one might wonder whether $t \mapsto \zeta(\tfrac12 + it)$ might be modeled by characteristic polynomial of a random matrix. Keating and Snaith used this idea to generate conjectures for moments of $\zeta(s)$ by computing the moments of characteristic polynomials in the CUE ensemble [which is an analogue of GUE where the eigenvalues are on the complex unit circle instead of the real line], and comparing with $\zeta(s)$. This idea is robust and applies to moments in Katz--Sarnak families.

2more comments