Example 5: Find $\nabla\cdot\left(\frac{\boldsymbol r}{r^2}\right)$ where $\boldsymbol r(x,y,z)=x\boldsymbol i+y\boldsymbol j+z\boldsymbol k$, $r=\sqrt{x^2+y^2+z^2}$.
In this case, why can we not bring the scalar function $r^{-2}$ outside the dot product?
When I leave the function in place, I calculate a result of $\frac{1}{r^{2}}$. When I pull it out, I find $\frac{3}{r^{2}}$.
It's not just a dot product, it's a divergence operator, and the variables $x,y,z$ appear in $r^{-2}$, it's not a constant.
However, you may use the product rule:
$$\nabla \cdot(\psi \boldsymbol F)=\psi \nabla\cdot \boldsymbol F+\nabla\psi\cdot \boldsymbol F$$
And with $\psi=r^{-2}$, it's not difficult to prove that
$$\nabla\psi=-\frac{2}{r^4}\boldsymbol r$$