The trivial/elementary proof (in particular, it does not use the axiom choice).
A ring $R$ satisfies your condition iff it satisfies the identity $x^3=x$.
Pf.
Will shows above with a short computation that if $R$ satisfies the condition, then the characteristic divides $6$. So if $z=e+f$ with $e,f$ commuting idempotents, then $z^3=(e+f)^3=e+6ef+f = e+f=z$.
Suppose $z^3=z$ for all elements of $R$. Now $R$ has characteristic dividing $6$ since $2=(1+1)^3=8$. Thus we have $R$ is a product $R_1\times R_2$ of a ring $R_1$ of characteristic $2$ and $R_2$ of characteristic $3$. The ring $R_1$ is boolean (using $z-1=(z-1)^3=z^3-3z^2+3z-1=z^2-1$, whence $z^2=z$) and so all elements are idempotent and we are done. So it suffices to handle $R_2$, i.e., assume the characteristic is $3$.
Note $z^2$ is idempotent and $z=z^2+(z-z^2)$. We claim the latter is idempotent. Then $(z-z^2)^2= z^2-2z^3+z^4=2z^2-2z=z-z^2$. Done.
Answer. I believe that the answer is that the ring be a subdirect product of copies of $Z/2$ and $Z/3$, which in this case is equivalent to being in the variety of rings generated by $Z/6$.
My original revised answer below says that a ring satisfying the desired condition is a subdirect product of copies of $Z/2$ and $Z/3$ and hence in the variety generated by $Z/6$.
Suppose $R$ is a ring in the variety generated by $Z/6$. Since $R$ is a direct limit of finitely generated rings and your property is closed under direct limit, we may assume that $R$ is finitely generated. But then $R$ is finite because a variety generated by a finite ring is locally finite.
But if $R$ is finite and in this variety, then $R$ is a reduced finite commutative ring and hence a finite direct product of domains belonging to the variety generated by $Z/6$. But $Z/2$ and $Z/3$ are the only domains in this variety.
Original Revised Answer. A necessary condition is that $R$ is a subdirect product of copies of $Z/2$ and $Z/3$.
Claim 1: The class of rings satisfying your property is closed under direct product and homomorphic images.
Pf. Exercise.
Claim 2: If the ring is indecomposable (not a direct product), then the ring either is a boolean algebra or satisfies $z^3=z$. Pf. See Will's answer and the comments.
Claim 3: the ring $R$ is reduced (i.e., has no non-zero nilpotents). Pf. Clear since it is a product of a ring satisfying $z^2=z$ and one satisfying $z^3=z$.
Theorem 12.7 in Lam's book on non-commutative rings shows a subdirectly irreducible reduced ring is an integral domain. Since 0,1 are the unique idempotents of an integral domain, we conclude that $R$ is subdirect product of $Z/2$ or $Z/3$.
Now boolean algebras (=subdirect products of $Z/2$) all have the desired property so it remains to see which subdirect products of $Z/3$ have the property.