The map $i:X\to\operatorname{Spec}(C(X))$ is a homeomorphism onto its image iff $X$ is completely regular; this is essentially the definition of complete regularity.  However, it is very rarely surjective.

Indeed, suppose $X$ is completely regular and $i:X\to\operatorname{Spec}(C(X))$ is surjective and hence a homeomorphism.  Then for any $f\in C(X)$, the subset $D(f)\subset\operatorname{Spec}(C(X))$ of prime ideals that do not contain $f$ is compact, being naturally homeomorphic to $\operatorname{Spec}(C(X)_f)$.  But this means that every cozero subset of $X$ is compact and thus clopen.  It follows easily that $X$ must be finite.  More generally, a similar argument shows that if the spectrum of a ring is Hausdorff, it must be totally disconnected.

Note, however, that for $X$ compact Hausdorff, the image of $i$ is exactly the maximal ideals of $C(X)$: the closure of any proper ideal is proper since every function sufficiently close to $1$ is invertible, so every maximal ideal is closed.  Furthermore, any prime ideal is contained in a unique maximal ideal: for any two points $x,y\in X$, we can find functions $f,g\in C(X)$ such that $fg=0$ but $f(x)\neq0$ and $g(y)\neq 0$, and so no prime can be contained in both $\mathfrak{m}_x$ and $\mathfrak{m}_y$.  So in some sense, $X$ really isn't that far from being the same as $\operatorname{Spec}(C(X))$.

Edit: Here's an example of what these non-maximal prime ideals might look like.  Let $X$ be the 1-point compactification of a countable discrete space and identify $C(X)$ with the ring of convergent sequences.  Fix a nonprincipal ultrafilter $U$ on $\mathbb{N}$ and let $P$ be the set of sequences $(x_n)$ which converge to $0$ and for which $(n^kx_n)$ converges to $0$ with respect to $U$ for all $k$.  Then I claim $P$ is a prime ideal (which is strictly contained in the maximal ideal corresponding to the point at infinity).  It is easy to see it is an ideal; suppose $(x_n)\not\in P$ and $(y_n)\not\in P$.  Then for $k$ sufficiently large, $(n^kx_n)$ and $(n^ky_n)$ both go to infinity with respect to $U$.  It follows that for large $k$, $(n^{2k}x_ny_n)$ also goes to infinity with respect to $U$, and thus $(x_ny_n)\not\in P$.