When did we move from $\mathbb{Z}\left[\sqrt{d}\right]$ to the ring of integers $\mathcal{O}_{\mathbb{Q}\left[\sqrt{d}\right]}$ and why? Gauss made great progress in number theory in $\mathbb{Z}$ by working in $\mathbb{Z}[i]$ (or equivalently $\mathbb{Z}\left[\sqrt{-1}\right]$), so much so that we call $\mathbb{Z}[i]$ the Gaussian integers now. And it was even known to the old mathematicians that solutions to Pell's equation $x^2 - dy^2 = 1$ could be better analysed by working in $\mathbb{Z}\left[\sqrt{d}\right]$.
But now in modern number theory we study much more the ring of integers $\mathcal{O}_{\mathbb{Q}\left[\sqrt{d}\right]}$. I find this confusing, as if we want to study Pell's equation with $d = 5$, we have that $\mathcal{O}_{\mathbb{Q}\left[\sqrt{5}\right]} = \mathbb{Z}\left[\frac{1 + \sqrt{5}}{2}\right]$ instead of $\mathbb{Z}\left[\sqrt{5}\right]$, which is not what we need. I was under the assumption that modern number theory usually tries to generalise its techniques but I don't see how this is a sensible generalisation and I don't see why the ring of integers is any more useful than just plain old $\mathbb{Z}\left[\sqrt{d}\right]$. So my question is:
Why is the ring of integers defined the way it is?
 A: You wrote "we have that $\mathcal{O}_{\mathbb{Q}\left[\sqrt{5}\right]} = \mathbb{Z}\left[\frac{1 + \sqrt{5}}{2}\right]$ instead of $\mathbb{Z}\left[\sqrt{5}\right]$, which is not what we need. "
This is not correct, we exactly need the ring of integers here, e.g., for most problems of algebraic number theory. The ring $\Bbb Z[\sqrt{5}]$ is not integrally closed, and hence not a Dedekind ring. So we cannot apply, among other things, the decomposition of ideals into prime ideals, which is crucial for many aspects.
Why do we need a decomposition for prime ideals here, and not for prime elements? Well, unfortunately the ring $\Bbb Z[\sqrt{5}]$  is not factorial, so we cannot proceed this way and we do need ideal decompositions.
Most rings appearing in number theory are no longer factorial, e.g. the rings $\Bbb Z[\zeta_n]$ for Fermat's equation $X^n+Y^n=Z^n$, but they are Dedekind rings, and this "recovers" some of the arguments we have for factorial rings - namely that $Z^n$ is an $n$-th power, so that writing
$$Z^n=X^n+Y^n=(X+Y)(X+\zeta_n Y)\cdots (X+\zeta_n^{n-1}Y)$$
as a product in the ring of integers of $\Bbb Z[\zeta_n]$ gives that the (coprime) factors are also $n$-th powers.
However, $\Bbb Z[\zeta_n]$ is only factorial for small $n$, so we can't argue this way.
Since $\Bbb Z[\zeta_n]$ is a Dedekind ring, we can write this as an ideal equation
$$
(Z)^n=(X^n+Y^n)=(X+Y)\cdot (X+\zeta_n=Y)\cdots (X+\zeta_n^{n-1}Y),
$$
and then at least make some progress.
A: We want rings of integers of number fields to be Dedekind domains, which are roughly speaking rings where prime factorization holds at least on the level of ideals. Integral closure is necessary for that.
