Motivation behind $X$ is an affine variety if and only if $I(X)$ is a prime ideal. It is not so difficult to prove that for any affine algebraic set $X$, $X$ is an affine variety if and only if the ideal $I(X)$ is prime. But I seem to be completely lacking the motivation behind this result. It would be great if someone could provide the algebro-geometric motivation behind this crucial fact.
 A: For simplicity fix a field $k$ over with the affine space $\mathbf{A}^n$ is defined. The idea here is that a variety $X \subset \mathbf{A}^n$ is always defined to be irreducible, i.e. it is not the union of two smaller spaces that are closed in the Zariski topology. And being an irreducible subspace $X$ in $\mathbf{A}^n$ is the same as requiring that the ideal sheaf $I_X \subset k[x_1,\dots,x_n]$ is a prime ideal.
In scheme theory, this concept is going to be generalised.
$\textbf{Edit}$: Or think of it this way: if you study manifolds, every property you'd study you study on its connected components. If it is not connected, you restrict to one component. The same here: If $X$ is reducible, i.e. its ideal sheaf $I$ looks like a product $fg$,for polynomials $f,g$,  then $X=V(f)\cup V(g)$ and you could study both vanishing sets separately.
A: If $X$ is an affine variety then it is plausible to think that if the product $fg$ vanishes on $X$ then either $f$ or $g$ must also vanish on whole of $X$ as $X$ is small (cannot be decomposed into smaller algebraic sets). The motivation for the converse is also similar.
