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))$.