These are exactly the finite spaces.
Completely regular topological spaces $X$ with the property that every prime ideal in $C(X)$ is maximal are called $P$-spaces. A topological characterization is: every $G_{\delta}$-set (countable intersection of open sets) is itself open.
It is not hard to show that countable subsets of $P$-spaces are closed and discrete. It follows that countably compact and in particular compact $P$-spaces are finite.
For a long list of equivalent characterizations and basic properties of $P$-spaces consult exercises 4J and 4K on pages 62 and 63 of Gillman-Jerison, Rings of continuous functions, Springer GTM 43, 1976.
In the MO-thread on prime ideals in $C[0,1]$ you'll also find some relevant information and constructions.