Why can the divergence of vector potential be anything? Purcell in his book was deriving the vector potential $\bf A$ using $\text{curl}\;(\text{curl}\; \mathbf A)= \mu_0 \mathbf J\; .$
After some algebra, he came to this:  $$-\frac{\partial^2 A_x}{\partial x^2}-\frac{\partial^2 A_x}{\partial y^2}- \frac{\partial^2 A_x}{\partial z^2} +\frac{\partial}{\partial x}\left(\frac{\partial A_x}{\partial x}+ \frac{\partial A_y}{\partial y}+\frac{\partial A_z}{\partial z}\right)= \mu_0 J_x.$$
Then he wrote:

[...] The quantity in parenthesis is the divergence of $\bf A\;.$ Now we have a certain latitude in the construction of $\bf A\; .$ All we care about is its curl; its divergence can be anything we like. Let us require that $$\text{div}\;\mathbf{A}= 0$$ ....

He gave the reason:

To see why we are free to do this, suppose we had an $\bf A$ such that $\text{curl}\;\mathbf A= \mathbf B,$  but $\text{div}\; \mathbf A= f(x,y,z)\ne 0.$ Treating $f$ like the charge density $\rho$ in electrostatic field , we obviously find a field $\bf F,$ the analogue of $\bf E,$ such that $\text{div}\; \mathbf F= f.$ But we know the curl of such a field is zero. Hence we could add $-\bf F$ to $A,$ making a new field with the correct curl and zero divergence.

I am having problem in understanding his reason.
First, shouldn't $\bf F$ be equal to $\bf A$ itself as the divergence of both is $f\;?$ Secondly, why should I add $-\bf F$ to $\bf A$ - wouldn't it nullify the function as both $\bf F$ & $\bf A$ are equal, isn't it?  
Can anyone please help me understand his reasoning why we are free to take anything for $\text{div}\; \mathbf A\;?$
 A: First, the physical thing we care about is $\vec B$. So we can do anything to $\vec A$ we like as long as we get the same $\vec B$. That is, we can do anything that doesn't change the curl of $\vec A$.
Now, suppose that $\vec \nabla\cdot\vec A = f$. Here's where Purcell neglects to stress what he means by "analogue of $\vec E$ in electrostatics" - the curl of an electrostatic field is zero! So $\vec F$ is a field with $\vec\nabla\cdot\vec F = f$, but $\vec \nabla\times\vec F = 0$. So $\vec A - \vec F$ now has zero divergence, but still the same curl.
A: You need to look up the Helmholtz Theorem and similar results that will basically give you ACuriousMind's Answer.
But a way I like to visualize this is through the Fourier transform; in Fourier space the curl $X\mapsto\nabla\times X$ and divergence $X\mapsto \nabla\cdot X$ become simply the cross $\tilde{X}\mapsto k\times\tilde{X}$ and scalar$\tilde{X}\mapsto k\cdot\tilde{X}$ product with the wavevector $k$. So we look at our transformed vector field $\tilde{X}$ in Fourier space: at any point $P$, the component $\tilde{X}_\parallel$ of $\tilde{X}$ along the ray joining  the origin and $P$ is the part that contributes to the divergence of $X$, and only this part can contribute to the divergence. Likewise, the component in the plane normal to $k$ is the component that contributes to the curl, and only this part contributes to the curl.
What Purcell is saying is that we are free to choose the component of $\tilde{X}$ along the wavevector to be anything we like. 
So, given an arbitrary (aside from usual convergence conditions) divergence $\nabla \cdot X$, we can find the required component $\tilde{\phi}(k)$ in Fourier space by solving the Poisson equation $\nabla^2 \phi = \nabla \cdot X$.
A: The search term you want is "gauge transformation," and if you read up on that (google comes up with lots of good hits), you'll find lots of different ways of thinking about this problem.
But it seems what has you confused is this: I think you're assuming that if two functions have the same divergence, then they must be the same. But think about what that would imply if it were true:
If $\nabla\cdot\vec{A}=\nabla\cdot\vec{B}$ implied $\vec{A}=\vec{B}$, then defining $\vec{C}=\vec{A}-\vec{B}$ would allow us to prove that $\nabla\cdot\vec{C}=0$ implies $\vec{C}=0$. But this can't be right, since we know that $\nabla\cdot\vec{E}=0$ governs the electric field in empty space, and there are lots of allowable nonzero electric fields in empty space.
Intuitively, the gradient is a scalar field with fewer degrees of freedom than the vector field. So specifying the gradient shouldn't give you enough information, in general, to determine the field. You need more equations of constraint than that.
A: Let us understand this conceptually. We have $\nabla\cdot\mathbf{B}=\mathbf{0}$, therefore we require a vector function $\mathbf{A}$ such that $\mathbf{B}=\nabla\times\mathbf{A}$ so that its divergence vanishes. As $\nabla\times\mathbf{B}=\mu_0\mathbf{J}$, we can write $\nabla(\nabla\cdot\mathbf{A})-\nabla^2 \mathbf{A}=\mu_0\mathbf{J}$. Now, it is possible to choose $\mathbf{A}$ such that its curl remains unaltered but its divergence vanishes. We are interested in this particular case because we would then get $\nabla^2\mathbf{A}=\mu_0\mathbf{J}$ which looks similar to Poisson's equation for scalar potential in electrostatics.
