There is a complete characterization of affine schemes $X=Spec(A)$ of dimension zero.
First, we may assume that the ring $A$ is reduced (i.e. that its only nilpotent is zero), because $A$ and $A_{red}=A/Nil(A)$ have homeomorphic spectra so that $dimSpec (A)=dimSpec (A_{red})$.
Then for a reduced ring $A$ and its associated affine scheme $X=Spec(A)$ the following statements are equivalent:
1. $X$ has dimension zero
2. Every localization $A_\mathfrak p \;(\mathfrak p\in X) $ is a field.
3. $A$ is von Neumann regular i.e.$\forall a\in A \;\;\exists b\in A$ with $a=ba^2$
It is very easy to use the von Neumann property and thus to build many examples of affine schemes of dimension zero.
For example any product of von Neumann regular rings is von Neumann regular and obviously a field is von Neumann regular, hence a completely arbitrary product of fields $A= \Pi_{i\in I}k_i$ has zero dimensional spectrum $Spec(A)$.
Note that already $Spec(k^{\mathbb N})$ is homeomorphic to the Stone-Čech compactification of $\mathbb N$ and has cardinality $2^{\mathfrak c}=2^{2^{\aleph_0}}$ but dimension zero.
Edit
By a happy coincidence our friend George Lowther has given us a link (in a comment to the question) to his answer on MathOverflow, which nicely illustrates the above ( George gives a different argument, not using von Neumann regularity ).
He considers a field $k$, a compact Hausdorff space $T$ and the ring $A\subset k^T$ of locally constant functions $f: T\to k$.
It is clear that $A$ is reduced, and trivial to see that it is von Neumann regular:
Indeed every $f\in A$ can be written $f=g\cdot f^2$ where we define $g$ by $g(t)=1/f(t)$ if $f(t)\neq0$ and by $g(t)=0$ if $f(t)=0$.
The function $g$ is clearly in $A$ since it is exactly as locally constant as $f$.
Hence $X=Spec(A)$ is always zero-dimensional and $X$ will be infinite as soon as $T$ has infinitely many open connected components, since the locally constant functions vanishing on one such connected component $U$ constitute a maximal ideal $\mathfrak m_U$.
George suggests taking for $T$ the one point compactification of the discrete space $\mathbb N$
Second Edit
seporhau, in a comment below, asks the interesting question: if $A=\Pi_{i\in I}A_i$ with $I$ arbitrary and all $A_i$'s zero-dimensional, may we conclude that $A$ is zero-dimensional?
The answer is yes if all the $A_i$'s are reduced, thanks to the equivalence above since in the reduced case the $A_i$'s must be von Neumann regular.
If the $A_i$'s are not reduced, however, the answer may be no:
I claim that the ring $A=\Pi_{n=1}^\infty \mathbb Z/2^n\mathbb Z$ is not zero-dimensional although all $\mathbb Z/2^n\mathbb Z$ are.
Indeed the Jacobson radical of $A$ is $Jac(A)=\Pi Jac(\mathbb Z/2^n\mathbb Z)=\Pi (2\mathbb Z/2^n\mathbb Z)$ and contains the sequence $(2,2,\cdots)$, whereas its nilradical does not contain that sequence.
This proves that $A$ does not have dimension zero, because in a zero-dimensional ring the Jacobson radical equals the nilradical.
Third edit
I have just learned on MathOverflow that $dim(\Pi_{n=1}^\infty \mathbb Z/2^n\mathbb Z)= \infty$
In the world of locally Noetherian schemes, Serre's criterion can be made quite geometric.
Let $X$ be a reduced, locally Noetherian scheme. Then...
- $X$ is $R_1$ iff the singular locus has codimension at least 2.
- $X$ is $S_2$ iff, for each $Y\subset X$ of codimension at least $2$, the regular functions on the complement $X-Y$ extend to regular functions on $X$.
This second fact can be found in Ravi Vakil's notes (Theorem 12.3.10), or in this MathOverflow post.
Roughly speaking, normalizing a variety improves singularities as follows.
- In codimension $1$, it completely resolves them.
- In codimension $\geq 2$, it improves them enough so that rational functions defined on their complement can be extended to the singularity.
Best Answer
No. According to this mathoverflow post, there is an example of an affine Noetherian integral scheme of dimension 1 whose regular locus is not open, see Exposé XIX of the volume "Travaux de Gabber" in Astérisque 363-364.
See comments by Remy and Rieux for nice sufficient conditions for the regular locus to be open.