You need to look up the Helmholtz Theorem and similar results that will basically give you ACuriousMind's AnswerACuriousMind'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$.