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.