The calculation result is:
$$\nabla \cdot \frac{1}{r^2} \hat{r} = \frac{1}{r^2} \frac{\partial}{\partial r} \left[r^2 \left( \frac{1}{r^2} \right) \right] = \frac 0 {r^2} = \begin{cases}0&,r\ne 0\\\\ \text{undefined}&,r=0\end{cases}$$
It correctly shows that the divergence is zero everywhere except the origin.
However, unfortunately, it only says that the divergence is not defined at the origin and cannot provide more information, that is, $\nabla \cdot \frac{1}{r^2} \hat{r}$ is actually positive infinity at the origin.
Nevertheless, we can use the following simple mathematical way to obtain the situation at the origin point.
Suppose there is a sphere centered on the origin, then the total flux on the surface of the sphere is : -
$$ \text {Total flux} = 4 \pi r^2 \left( \frac {1} {r^2} \right)= 4 \pi $$
Suppose the volume of the sphere be $ \mathbf {v(r)}$, so by the definition, the divergence is : -
$$ \lim_{\text {volume} \to zero} \frac {\text {Total Flux}} {\text {Volume}} = \lim_{\text {r} \to 0} \left(\frac {4 \pi} {v(r)}\right) $$
So obviously,
$$ \lim_{\text {r} \to 0} \left[ \nabla \cdot \left( \frac{1} {r^2} \hat r \right) \right] = \lim_{\text {r} \to 0} \left(\frac {4 \pi} {v(r)} \right) = \text {positive infinite} \qquad (1)$$
$$ \lim_{\text r\to 0} \int \nabla \cdot \left( \frac 1 {r^2} \hat r \right) dv(r) = \lim_{\text r\to 0}\int \frac {4 \pi} {v(r)} dv(r) = 4\pi \qquad (2)$$
Since the laplacian is zero everywhere except $r \to 0$, and according to equation (1) and (2), it is true and real that :-
$$ \nabla \cdot \left(\frac{1}{r^2} \hat r\right)=4\pi\delta^3({\bf r}) $$