In Peskin and Schroeder’s Introduction to Quantum Field Theory, the quantisation of the free scalar field is done by analogy with the classical one-dimensional harmonic oscillator, which is described by the Hamiltonian
$$H=\frac{1}{2}p^2 + \frac{1}{2}\omega^2x^2,$$
where $p$ is the momentum and $x$ the displacement of the oscillator. The standard ansatz is to expand the momentum and position operators in terms of ladder operators:
$$x = \frac{1}{\sqrt{2\omega}} \left(a+a^\dagger\right), \;\,\;\,\;\, p = -i\sqrt{\frac{\omega}{2}} \left(a-a^\dagger\right),$$
which can easily be inverted to give
$$a = \sqrt{\frac{\omega}{2}}q + \frac{i}{\sqrt{2\omega}}p, \;\,\;\,\;\, a^\dagger = \sqrt{\frac{\omega}{2}}q\; – \frac{i}{\sqrt{2\omega}}p.$$
With these relations in hand, it is not difficult to prove that the commutation relations
$$[x,x]=[p,p]=0,\;\,\;\,\;\, [x,p]=i$$
are equivalent to
$$[a,a]=[a^\dagger,a^\dagger]=0,\;\,\;\,\;\, [a,a^\dagger]=1.$$
For the scalar field $\phi(\mathbf{x})$ and its momentum conjugate $\pi(\mathbf{x})$, we can do something similar by expanding their Fourier transforms in terms of ladder operators:
$$\phi(\mathbf{x}) = \int\frac{\mathrm{d}^3p}{(2\pi)^3}\frac{1}{\sqrt{2\omega}}\left[a_\mathbf{p}e^{i\mathbf{p}\cdot\mathbf{x}}+a_\mathbf{p}^\dagger e^{-i\mathbf{p}\cdot\mathbf{x}}\right],\\
\pi(\mathbf{x}) = -i\int\frac{\mathrm{d}^3p}{(2\pi)^3}\sqrt{\frac{\omega}{2}}\left[a_\mathbf{p}e^{i\mathbf{p}\cdot\mathbf{x}}-a_\mathbf{p}^\dagger e^{-i\mathbf{p}\cdot\mathbf{x}}\right].$$
Given the commutation relations
$$[a_\mathbf{p},a_\mathbf{q}]=[a_\mathbf{p}^\dagger,a_\mathbf{q}^\dagger]=0,\\
[a_\mathbf{p},a_\mathbf{q}^\dagger]=(2\pi)^3\delta^{(3)}(\mathbf{p}-\mathbf{q}),$$
it is now straightforward to prove the relations
$$[\phi(\mathbf{x}),\phi(\mathbf{y})]=[\pi(\mathbf{x}),\pi(\mathbf{y})]=0,\\
[\phi(\mathbf{x}),\pi(\mathbf{y})]=i\delta^{(3)}(\mathbf{x}-\mathbf{y}).$$
However, the reverse implication is not immediately obvious and is not proved in the book, even though it seems more natural to assume the canonical commutation relation and then derive the commutators for the ladder operators. To prove the reverse direction, first assume that the commutation relations for $\phi(\mathbf{x})$ and $\pi(\mathbf{x})$ hold. We write
$$0 = [\phi(\mathbf{x}),\phi(\mathbf{y})] = \int\frac{\mathrm{d}^3p}{(2\pi)^3}\frac{\mathrm{d}^3q}{(2\pi)^3}\frac{1}{2\sqrt{\omega_\mathbf{p}\omega_\mathbf{q}}}\left[[a_\mathbf{p},a_\mathbf{q}]e^{i(\mathbf{p}\cdot\mathbf{x}+\mathbf{q}\cdot\mathbf{y})}+[a^\dagger_\mathbf{p},a_\mathbf{q}]e^{i(-\mathbf{p}\cdot\mathbf{x}+\mathbf{q}\cdot\mathbf{y})}\right.\\
\left.+[a_\mathbf{p},a^\dagger_\mathbf{q}]e^{i(\mathbf{p}\cdot\mathbf{x}-\mathbf{q}\cdot\mathbf{y})}+[a^\dagger_\mathbf{p},a^\dagger_\mathbf{q}]e^{i(-\mathbf{p}\cdot\mathbf{x}-\mathbf{q}\cdot\mathbf{y})}\right],\\
0 = [\pi(\mathbf{x}),\phi(\mathbf{y})] = -\int\frac{\mathrm{d}^3p}{(2\pi)^3}\frac{\mathrm{d}^3q}{(2\pi)^3}\frac{\sqrt{\omega_\mathbf{p}\omega_\mathbf{q}}}{2}\left[[a_\mathbf{p},a_\mathbf{q}]e^{i(\mathbf{p}\cdot\mathbf{x}+\mathbf{q}\cdot\mathbf{y})}-[a^\dagger_\mathbf{p},a_\mathbf{q}]e^{i(-\mathbf{p}\cdot\mathbf{x}+\mathbf{q}\cdot\mathbf{y})}\right.\\
\left.-[a_\mathbf{p},a^\dagger_\mathbf{q}]e^{i(\mathbf{p}\cdot\mathbf{x}-\mathbf{q}\cdot\mathbf{y})}+[a^\dagger_\mathbf{p},a^\dagger_\mathbf{q}]e^{i(-\mathbf{p}\cdot\mathbf{x}-\mathbf{q}\cdot\mathbf{y})}\right].$$
Because we integrate over the entire domain and because $\omega_\mathbf{p}=\omega_{-\mathbf{p}}$, we are allowed to substitute $-\mathbf{p}$ for $\mathbf{p}$ (and similarly for $\mathbf{q}$) in any of the four terms within the brackets. This gives us the following relation
$$0 = \int\frac{\mathrm{d}^3p}{(2\pi)^3}\frac{\mathrm{d}^3q}{(2\pi)^3} \left[f_1(\mathbf{p},\mathbf{q})e^{i(\mathbf{p}\cdot\mathbf{x}+\mathbf{q}\cdot\mathbf{y})}+f_2(\mathbf{p},\mathbf{q})e^{-i(\mathbf{p}\cdot\mathbf{x}-\mathbf{q}\cdot\mathbf{y})}+f_3(\mathbf{p},\mathbf{q})e^{-i(\mathbf{p}\cdot\mathbf{x}+\mathbf{q}\cdot\mathbf{y})}\right]\\
= \int\frac{\mathrm{d}^3p}{(2\pi)^3}\frac{\mathrm{d}^3q}{(2\pi)^3} \left[g_1(\mathbf{p},\mathbf{q})e^{i(\mathbf{p}\cdot\mathbf{x}+\mathbf{q}\cdot\mathbf{y})}+g_2(\mathbf{p},\mathbf{q})e^{-i(\mathbf{p}\cdot\mathbf{x}-\mathbf{q}\cdot\mathbf{y})}+g_3(\mathbf{p},\mathbf{q})e^{-i(\mathbf{p}\cdot\mathbf{x}+\mathbf{q}\cdot\mathbf{y})}\right],$$
where I have introduced the functions
$$f_1(\mathbf{p},\mathbf{q})=\frac{[a_\mathbf{p},a_\mathbf{q}]}{\sqrt{\omega_\mathbf{p}\omega_\mathbf{q}}}, \;\,\;\,\;\, f_2(\mathbf{p},\mathbf{q})=\frac{[a^\dagger_\mathbf{p},a_\mathbf{q}] + [a_{-\mathbf{p}},a^\dagger_{-\mathbf{q}}]}{\sqrt{\omega_\mathbf{p}\omega_\mathbf{q}}}, \;\,\;\,\;\, f_3(\mathbf{p},\mathbf{q})=\frac{[a^\dagger_\mathbf{p},a^\dagger_\mathbf{q}]}{\sqrt{\omega_\mathbf{p}\omega_\mathbf{q}}},\\
g_1(\mathbf{p},\mathbf{q})=\omega_\mathbf{p}\omega_\mathbf{q}\;f_1(\mathbf{p},\mathbf{q}), \;\,\;\,\;\, g_2(\mathbf{p},\mathbf{q})=-\omega_\mathbf{p}\omega_\mathbf{q}\;f_2(\mathbf{p},\mathbf{q}), \;\,\;\,\;\, g_3(\mathbf{p},\mathbf{q})=\omega_\mathbf{p}\omega_\mathbf{q}\;f_3(\mathbf{p},\mathbf{q}).$$
The takeaway is that because the exponentials $\exp(\pm i\mathbf{p}\cdot\mathbf{x}\pm i\mathbf{q}\cdot\mathbf{y})$ are linearly independent, we must have that $f_i(\mathbf{p},\mathbf{q})=g_i(\mathbf{p},\mathbf{q})=0$. Hence, we find in particular that
$$[a_\mathbf{p},a_\mathbf{q}]=[a_\mathbf{p}^\dagger,a_\mathbf{q}^\dagger]=0.$$
Deriving the final commutator takes some more work. We start with the third relation between $\phi(\mathbf{x})$ and $\pi(\mathbf{y})$:
$$i\delta^{(3)}(\mathbf{x}-\mathbf{y})=[\phi(\mathbf{x}),\pi(\mathbf{y})] = \frac{-i}{2}\int\frac{\mathrm{d}^3p}{(2\pi)^3}\frac{\mathrm{d}^3q}{(2\pi)^3}\left[[a_\mathbf{p},a_\mathbf{q}]e^{i(\mathbf{p}\cdot\mathbf{x}+\mathbf{q}\cdot\mathbf{y})}-[a^\dagger_\mathbf{p},a_\mathbf{q}]e^{i(-\mathbf{p}\cdot\mathbf{x}+\mathbf{q}\cdot\mathbf{y})}\right.\\
\left.+[a_\mathbf{p},a^\dagger_\mathbf{q}]e^{i(\mathbf{p}\cdot\mathbf{x}-\mathbf{q}\cdot\mathbf{y})}-[a^\dagger_\mathbf{p},a^\dagger_\mathbf{q}]e^{i(-\mathbf{p}\cdot\mathbf{x}-\mathbf{q}\cdot\mathbf{y})}\right]\\
= \frac{-i}{2}\int\frac{\mathrm{d}^3p}{(2\pi)^3}\frac{\mathrm{d}^3q}{(2\pi)^3}\left[-[a^\dagger_\mathbf{p},a_\mathbf{q}]e^{i(-\mathbf{p}\cdot\mathbf{x}+\mathbf{q}\cdot\mathbf{y})}+[a_\mathbf{p},a^\dagger_\mathbf{q}]e^{i(\mathbf{p}\cdot\mathbf{x}-\mathbf{q}\cdot\mathbf{y})}\right].$$
Multiplying the left hand side by $\int\mathrm{d}^3x\;\mathrm{d}^3y\; e^{-i(\mathbf{p’}\cdot\mathbf{x}+\mathbf{q’}\cdot\mathbf{y})}$ gives
$$\int\mathrm{d}^3x\;\mathrm{d}^3y\; e^{-i(\mathbf{p’}\cdot\mathbf{x}+\mathbf{q’}\cdot\mathbf{y})}i\delta^{(3)}(\mathbf{x}-\mathbf{y})=\int\mathrm{d}^3y\; e^{-i(\mathbf{p’}+\mathbf{q’})\cdot\mathbf{y}}i(2\pi)^3\\
=i\delta^{(3)}(\mathbf{p’}-\mathbf{q’})(2\pi)^3.$$
The right hand side becomes
$$-\frac{i}{2}\int\mathrm{d}^3x\;\mathrm{d}^3y\frac{\mathrm{d}^3p}{(2\pi)^3}\frac{\mathrm{d}^3q}{(2\pi)^3}\left[-[a^\dagger_\mathbf{p},a_\mathbf{q}]e^{i(-(\mathbf{p}+\mathbf{p’})\cdot\mathbf{x}+(\mathbf{q}-\mathbf{q’})\cdot\mathbf{y})}+[a_\mathbf{p},a^\dagger_\mathbf{q}]e^{i((\mathbf{p}-\mathbf{p’})\cdot\mathbf{x}-(\mathbf{q}+\mathbf{q’})\cdot\mathbf{y})}\right]\\
=-\frac{i}{2}\left[-[a^\dagger_{-\mathbf{p’}},a_\mathbf{q’}]+[a_\mathbf{p’},a^\dagger_{-\mathbf{q’}}]\right]\\
=i[a^\dagger_{-\mathbf{p’}},a_\mathbf{q’}],$$
where we used $f_2(\mathbf{p},\mathbf{q})=g_2(\mathbf{p},\mathbf{q})=0$ in the final step. It follows that
$$\delta^{(3)}(\mathbf{p}-\mathbf{q})(2\pi)^3 = [a^\dagger_\mathbf{p},a_\mathbf{q}],$$
if we simply substitute $\mathbf{p}$ for $-\mathbf{p’}$ and $\mathbf{q}$ for $\mathbf{q’}$. This is what we wanted to show.