Griffiths (Introduction to Quantum Mechanics, 3rd edition, §7.1.2) presents the following derivation for first-order energy perturbations in nondegenerate time-independent perturbation theory.
Suppose we have a time-independent Hamiltonian $H=H^0+\lambda H'$, with known, unperturbed, orthonormal, and possibly degenerate energy eigenstates $H^0\psi_n^0=E_n^0\psi_n^0$. Expanding the time-independent Schrödinger equation for $H$ as a power series in $\lambda$, we have: $$\left(H^0+\lambda H'\right)\sum_{k=0}^\infty\lambda^k\psi_n^k=\left(\sum_{k=0}^\infty\lambda^kE_n^k\right)\left[\sum_{k=0}^\infty\lambda^k\psi_n^k\right]$$ $$\implies H^0\psi_n^0+\lambda\left(H^0\psi_n^1+H'\psi_n^0\right)+\mathcal{O}\left(\lambda^2\right)=E_n^0\psi_n^0+\lambda\left(E_n^0\psi_n^1+E_n^1\psi_n^0\right)+\mathcal{O}\left(\lambda^2\right)$$ To first order in $\lambda$, we then have: $$H^0\psi_n^1+H'\psi_n^0=E_n^0\psi_n^1+E_n^1\psi_n^0$$ $$\implies\langle{\psi_n^0}|{H^0\psi_n^1}\rangle+\langle{\psi_n^0}|{H'\psi_n^0}\rangle=\langle{\psi_n^0}|{E_n^0\psi_n^1}\rangle+\langle{\psi_n^0}|{E_n^1\psi_n^0}\rangle$$ $$\implies\boxed{E_n^1=\langle{\psi_n^0}|H'|{\psi_n^0}\rangle}$$ However, we know that this correction breaks down in degenerate perturbation theory; the actual first-order correction to the energy requires that we use "good" states instead of arbitrary unperturbed states.
At what point has the derivation above failed? What assumptions have we made that we were not allowed to make?