As far as I can remember, the formula you obtain is right. You can make this "problematic" integral disappear by using the following identity, that we will call "curl theorem" :
$$\int\vec{\nabla}\times\vec{w}dV = -\int\vec{w}\times d\vec{S}$$
To show this is true, we are going to use the divergence or Green-Ostrogradski theorem, namely
$$\int\vec{\nabla}\cdot \vec{v}dV = \int \vec{v}\cdot d\vec{S}$$
Since the divergence theorem is a scalar identity while the curl theorem is a vector identity, we are going to need three distinct vector fields that we are going to denote $\vec{v}_i$. Now, we would want $\vec{\nabla}\cdot\vec{v}_i = (\vec{\nabla}\times\vec{w})_i$ to deduce an identity on the curl. Writing that in tensor notation :
$$\partial^k(v_i)_k=\epsilon_{ikl}\partial^k w^l$$
As we can see, it is sufficient to take $(\vec{v}_i)_k = \epsilon_{ikl}w^l$ and the relation will be satisfied. So, for such a vector field we have $\vec{\nabla}\cdot\vec{v}_i = (\vec{\nabla}\times\vec{w})_i$.
Applying the divergence theorem to $\vec{v}_i$ :
$$\int(\vec{\nabla}\times\vec{w})_idV = \int\vec{\nabla}\cdot\vec{v}_idV = \int\vec{v_i}\cdot d\vec{S} = \int (v_i)_k(d\vec{S})^k = \int\epsilon_{ikl}w^l(d\vec{S})^k = -\int(\vec{w}\times d\vec{S})_i$$
Thus giving a proof of the "curl theorem". Using it on your problematic integral :
$$-\frac{\mu_0}{4\pi}\int\nabla'\times\left(\frac{\mathbf{J}(\mathbf{x}')}{|\mathbf{x}-\mathbf{x}'|}\right)\,d^3\mathbf{x}' = -\frac{\mu_0}{4\pi}\int\left(\frac{\mathbf{J}(\mathbf{x}')}{|\mathbf{x}-\mathbf{x}'|}\right)\,\times d\vec{S}'$$
Now, the volume integral is done on all of space, and provided you suppose that $\lim_{x'\rightarrow\infty}\frac{\vec{J}(x')}{|x-x'|} = 0$, it gives a 0 contribution. Why does this not add any crazy assumptions ?
For this limit to be non-zero, we must necessarily have that $|J(x)|$ tend to infinity. Indeed, suppose $J(x)$ is finite. Then, there is a constant $C$ such that $|J(x)|<C$. Then, $lim_{x'\rightarrow\infty}\frac{|J(x')|}{|x-x'|}<\lim_{x'\rightarrow\infty}\frac{C}{|x-x'|} = 0$. Thus, if we were to have this "extra" integral not vanish, we would be required to have an infinite current density at infinity, which seems to be not so physical.
Of course, all my derivation where done in the context of well-behaved functions. It won't work say for an infinitely small wire, as the current density becomes a distribution (using the dirac delta $\delta(x)$). I am not qualified enough to tackle this case rigorously, but I hope the explanation above gives an idea to why setting this integral to 0 is sensible.
Best Answer
I think the better way to derive this is to first observe the Biot-Savart law, $$ \mathbf B(\mathbf r)=\frac{\mu_0}{4\pi}\int\mathbf J(\mathbf r')\times\frac{\hat{r}}{r^2}\,\mathrm dV'\tag{1} $$ Since $$ \frac{\hat r}{r^2}=-\nabla_r\left(\frac1r\right) $$ (your text may derive this, if not you can prove it by starting with the RHS), we can write (1) as $$ \mathbf B(\mathbf r)=-\frac{\mu_0}{4\pi}\int\mathbf J(\mathbf r')\times\nabla_r\left(\frac{1}{r}\right)\,\mathrm dV'\tag{2} $$ Since $\mathbf J$ is a function or $r'$ and not $r$, we can put it inside the parenthesis and swap the order of the cross product (i.e., $\mathbf J\times\nabla=-\nabla\times\mathbf J$), $$ \mathbf B(\mathbf r)=\frac{\mu_0}{4\pi}\int\nabla_r\times\frac{\mathbf J(r')}{r}\,\mathrm dV'\tag{3}=\nabla_r\times\frac{\mu_0}{4\pi}\int\frac{\mathbf J(r')}{r}\,\mathrm dV' $$ Then we can define the vector potential as $$ \mathbf A(\mathbf r)=\frac{\mu_0}{4\pi}\int\frac{\mathbf J(r')}{r}\,\mathrm dV' $$ To get $$ \mathbf B(\mathbf r)=\nabla\times\mathbf A(\mathbf r)\tag{4} $$ where we drop the subscript $r$ because it's implied that it's over $\mathbf r$.
That proof over, we can take the divergence of (4): $$ \nabla\cdot\mathbf B=\nabla\cdot\nabla\times\mathbf A\equiv0 $$ by the fact that the divergence of every curl is identically zero (worth the effort to prove this).