There are a couple of ways to derive this, Ill sketch out what I think is the most intuitive.
If you write out the algebra for $\nabla \cdot \nabla (1/\vert \vec{x}-\vec{x}'\vert) $ you will find formally that it is zero. However the algebraic manipulations you perform are only valid in a neighborhood where the functions is continuous and differentiable. There is one glaring place where that isn't true and that is when $\vec{x}=\vec{x}'$.
The question is how can we define the divergence of the gradient at a point where it technically doesn't exist. The key is by thinking of the divergence of a vector field at a point as the flux per unit volume of the vector field at the given point. This is motivated by Gauss' Theorem,
$$ \int_{\partial V} \vec{A} \cdot d\vec{a} = \int_V \nabla \cdot V dV$$
So to find the divergence at $\vec{x}=\vec{x}'$ we calculate the flux of the gradient over the surface of a sphere centered at $\vec{x}'$ and then evaluate the limit of the flux as the radius of the sphere goes to $0$.
$$ Flux = \int_S \nabla \frac{1}{\vert \vec{x} - \vec{x}'\vert } \cdot \hat{n} da = -\int_S \frac{\vec{x} - \vec{x}'}{\vert \vec{x} - \vec{x}' \vert^3} \cdot \frac{\vec{x} - \vec{x}'}{\vert \vec{x} - \vec{x}' \vert } da \int_S \frac{\vec{R}}{R^3} \cdot \frac{\vec{R}}{R} R^2 d\Omega = \int_S d\Omega = -4\pi$$
So the flux per unit volume is $\lim_{R\rightarrow 0 } -4\pi/V = \infty$. We have that the lapacian of our function is zero everywhere $ \vec{x} \neq \vec{x}'$ and is infinite at $\vec{x}=\vec{x'}$ but integrates to a finite value. This is clearly a delta function so we conclude that,
$$ \nabla^2 \frac{1}{\vert \vec{x} - \vec{x}' \vert} = -4\pi \delta^{(3)}(\vec{x}-\vec{x}') $$
Thought I would add an explanation about what a delta function is:
A Dirac delta function can be thought of as a normalized distribution which is nonzero only at one point.
So we write,
$$ \delta^{(3)}(\vec{x}) = \begin{cases} 0 \quad \text{when } \vec{x} \neq 0 \\ \infty \quad \text{when } \vec{x} = 0 \end{cases} $$
with the understanding that
$$ \int_{V} \delta^{(3)}(\vec{x}) dV = \begin{cases} 1 \quad \text{if } 0 \in V \\ 0 \quad \text{if } 0 \notin V \end{cases}$$
You can construct such a "function" by taking the limit of some appropriate distribution. In 1 dimension we could write,
$$ \int \delta(x) f(x) dx = \lim_{n \rightarrow \infty} \int \delta_n(x) f(x) dx; \quad \text{where} \quad \delta_n(x) = \sqrt{\frac{n}{\pi}} e^{-n x^2}$$
Notice the importance of keeping the limit outside of the integral otherwise we wouldn't have something we could integrate.