In perturbation theory, if
\begin{align}{\hat {H}} &= {\hat {H}^{(0)}} + λ{\hat {H}^{(1)}} \tag{1}\\ {ψ} &= {ψ^{(0)}} + λ{ψ^{(1)}} +λ^2{ψ^{(2)}} + ... \tag{2}\\ {E} &= {E^{(0)}} + λ{E^{(1)}} +λ^2{E^{(2)}} + ... \tag{3}\\ \end{align}
then, by applying these three equations on ground state $ψ_0$ and using the general time-independent ${\hat {H}{ψ} = Eψ}$ , it can be shown that:[1]
$$E_0^{(2)} = \sum_{n \neq 0}\frac{|H_{n0}|^2}{E_{0}^{{(0)}}-E_n^{(0)}} \tag{4}$$
The proof can be found in quoted reference; it is too long and not shown here. There is one step reads:
\begin{align}\int{ψ^{(0)*}_0}&\hat {H}^{(0)}{ψ^{(2)}_0} dτ + \int{ψ^{(0)*}_0}\hat {H}^{(1)}{ψ^{(1)}_0} dτ = \\ &E^{(2)}_0\int{ψ^{(0)*}_0}{ψ^{(0)}_0} dτ + E^{(1)}_0\int{ψ^{(0)*}_0}{ψ^{(1)}_0} dτ + E^{(0)}_0\int{ψ^{(0)*}_0}{ψ^{(2)}_0} dτ\tag{5}\end{align} the first and last terms cancel.
I don't see why the first term (on LHS) is equal to the last term (on RHS). Based on the first three equations above, we can only conclude
$$\hat {H}^{(0)}{ψ^{(0)}_0} = {E}^{(0)}_0{ψ^{(0)}_0} \tag{6}$$
Why is $\hat {H}^{(0)}{ψ^{(2)}_0} = {E}^{(0)}_0{ψ^{(2)}_0} $? Also, why is ${ψ^{(2)}_0}$ also an eigenfunction of $\hat {H}^{(0)}$, with same eigenvalue as that of ${ψ^{(0)}_0}$? I believe it has something to do with linearity of quantum mechanics, but not able to prove it.
Reference
[1]: Peter Atkins, Julio de Paula. Physical Chemistry (8th Edition). OUP. 2006. Page 314-315.