Ricci-flat vs Riemann-flat Why for the n-dimensional Riemannian manifold (with $n=2$ or $3$) the Ricci curvature tensor and the Riemann tensor are the same, while for $n>3$ not?
For example if I have 2-manifold (or 3-manifold) $M$ that is Ricci-flat, then it is also Riemann-flat, but if I have 4-manifold $M$ that is Ricci-flat, may be not Riemann-flat.
 A: Here are the precise claims.


*

*When $n=2$, one has $\operatorname{Ric}=\frac{1}{2}Rg$ and $R_{ijkl}=\frac{1}{2}R(g_{il}g_{jk}-g_{ik}g_{jl})$

*When $n=3$, one has $R_{ijkl}=g_{il}R_{jk}-g_{ik}R_{jl}-g_{jl}R_{ik}+g_{jk}R_{il}-\frac{1}{2}R(g_{il}g_{jk}-g_{ik}g_{jl})$
So you can directly see that when $n=2$, zero scalar curvature implies zero Ricci curvature and zero Riemann curvature, and that zero Ricci curvature implies zero scalar curvature and hence zero Riemann curvature.
And when $n=3$, zero Ricci curvature implies zero Riemann curvature but zero scalar curvature does not necessarily imply zero Riemann curvature or zero Ricci curvature. A standard counterexample, written in a single coordinate chart, is the "Riemannian Schwarzschild manifold" $\frac{dr^2}{1-\frac{2M}{r}}+r^2\,d\theta^2+r^2\sin^2\theta\,d\phi^2$ where $M$ is any real number; it has zero scalar curvature but nonzero Ricci curvature and Riemann curvature.
-
To prove the above formulas:


*

*when $n=2$, let $e_1,e_2$ be a $g$-orthonormal basis of $T_pM$. Then the definition of $R$ and then of $\operatorname{Ric}$ says $$R=\operatorname{Ric}(e_1,e_1)+\operatorname{Ric}(e_2,e_2)=\operatorname{Rm}(e_2,e_1,e_1,e_2)+\operatorname{Rm}(e_1,e_2,e_2,e_1)$$
so that $R=2\operatorname{Rm}(e_1,e_2,e_2,e_1).$ This directly shows that $R_{ijkl}=\frac{1}{2}R(g_{il}g_{jk}-g_{ik}g_{jl})$ holds when evaluated on $(e_1,e_2,e_2,e_1)$. By the simple symmetries of the Riemann tensor, it also holds when evaluated on $(e_1,e_2,e_1,e_2)$, on $(e_2,e_1,e_1,e_2)$, and on $(e_2,e_1,e_2,e_1).$ And both sides are trivially zero when evaluated on $(e_i,e_j,e_k,e_k)$ when $i=j$ or $k=l$. This covers all possibilities, so the given formula holds for any input. One trace of it gives $\operatorname{Ric}=\frac{1}{2}Rg.$

*The same sort of proof works when $n=3$ but is a bit more complicated. Let $W_{ijkl}$ denote the difference of the LHS and the proposed RHS; it is easy to check $g^{il}W_{ijkl}=0.$ Let $e_1,e_2,e_3$ be a $g$-orthonormal basis of $T_pM$ and evaluate $g^{il}W_{ijkl}=0$ on $(e_1,e_1)$; it says that
$$W(e_1,e_1,e_1,e_1)+W(e_2,e_1,e_1,e_2)+W(e_3,e_1,e_1,e_3)=0.$$
The first term vanishes since the original LHS and RHS both vanish when evaluated on $(e_1,e_1,e_1,e_1).$ So
$$W(e_2,e_1,e_1,e_2)=-W(e_3,e_1,e_1,e_3).$$
Repeating the same proof but starting from $(e_2,e_2)$ and $(e_3,e_3)$, we have
$$W(e_1,e_2,e_2,e_1)=-W(e_3,e_2,e_2,e_3)$$
and
$$W(e_1,e_3,e_3,e_1)=-W(e_2,e_3,e_3,e_2).$$
And the definition of $W$ shows easily that $W(e_a,e_b,e_b,e_a)=W(e_b,e_a,e_a,e_b).$ So (writing $W_{abcd}$ to abbreviate $W(e_a,e_b,e_c,e_d)$) there is
$$W_{2112}=-W_{3113}=-W_{1331}=W_{2332}=W_{3223}=-W_{1221}=-W_{2112}.$$
So $W_{2112}=0$, and likewise $W_{abba}=0$ for any $a$ and $b$. It is easy to see from the definition of $W$ that $W_{aabc}=0$ and $W_{bcaa}=0$ for any $a,b,c.$ With a little thinking, since $a,b,c$ are only between $1$ and 3, the only possibly nonzero components are $W_{abca}$ where $a,b,c$ are all distinct. To see that these vanish, evaluate $g^{il}W_{ijkl}=0$ on $(e_b,e_c)$ to get
$$W_{1bc1}+W_{2bc2}+W_{3bc3}=0.$$
Supposing, for instance, that $(b,c)=(2,3)$, this shows that $W_{1231}=0.$ If $(b,c)=(1,3)$, it shows that $W_{2132}=0$. And so on. 
I learned the argument from page 276-277 of Hamilton's paper "Three-manifolds with positive Ricci curvature" but the proof probably goes back to the early 1900s.
A: @youler's answer addresses the OP's question for $n < 4$, but I felt that something was missing that is crucial for understanding the answer to this question:

For example if I have 2-manifold (or 3-manifold) $M$ that is Ricci-flat, then it is also Riemann-flat, but if I have 4-manifold $M$ that is Ricci-flat, may be not Riemann-flat.

The answer is that the Riemann tensor can be decomposed, where the traceless component is the Weyl tensor. Generally, the Weyl curvature is the only component of curvature for Ricci-flat manifolds. The Ricci tensor measures how much an object's volume changes as it moves along a geodesic, and the Weyl tensor measures how much an object's shape changes as it moves along a geodesic. This is why (essentially) a necessary condition for a Riemannian manifold to be conformally flat is that the Weyl tensor vanishes.
When you have a Ricci-flat manifold that is also not Riemann-flat, it is because the Weyl tensor is nonzero. A classic example is the Schwarszchild metric in vacuum, which is Ricci-flat but is not Riemann-flat because the Weyl tensor is non-vanishing.
