This is mainly a rehash of previous answers. In the realm of Riemannian
geometry, we have the Riemannian covariant derivative $\nabla$ and, besides
the contraction of covariant with contravariant tensors, the metric
contraction of tensors of the same type, i.e., using the isomorphism
$g:TM\rightarrow T^{\ast}M$. Let $X,Y,Z$ denote vector fields and $f$ be a
function. The basic contraction is: If $\alpha$ is a $1$-form, then
$\alpha(Y)$ is a function.

We have $\nabla_{X}f=X(f)$, i.e., $\nabla f=df$. Thinking of a contraction as
a product, commuting with contraction (CWC) is like the product rule:
$X(\alpha(Y))=(\nabla_{X}\alpha)(Y)+\alpha(\nabla_{X}Y)$. This defines the
covariant derivative of a $1$-form. Similarly, for a $2$-tensor $\beta$ we
have: $X(\beta(Y,Z))=(\nabla_{X}\beta)(Y,Z)+\beta(\nabla_{X}Y,Z)+\beta
(Y,\nabla_{X}Z)$ by CWC; think of $\beta(Y,Z)$ as $\beta\cdot Y\cdot Z$ and
apply $\nabla_{X}$ to it with the product rule in effect. The compatibility of
the $\nabla$ with $g$ is usually written as: $X(g(Y,Z))=g(\nabla
_{X}Y,Z)+g(Y,\nabla_{X}Z)$, which is equivalent to $\nabla_{X}g=0$.

At a point $x$, the trace, or metric contraction, of a $2$-tensor $\beta$ is
given by the following formula:
$$
\operatorname{Trace}{}_{g}(\beta)=\frac{1}{\omega_{n}}\int_{S^{n-1}}
\beta(V,V)d\sigma(V),
$$
where $S^{n-1}\subset T_{x}M$ is the unit $\left( n-1\right) $-sphere,
$n\omega_{n}$ is its volume, and $d\sigma$ is its volume form. Without loss of
generality, we may assume that we are in $\mathbb{R}^{n}$, in which case
$\beta(V,V)=\sum_{i,j=1}^{n}\beta_{ij}V_{i}V_{j}$. The formula follows from
$\int_{S^{n-1}}V_{i}V_{j}d\sigma(V)=0$ for $i\neq j$ and $n\int_{S^{n-1}}
V_{i}^{2}d\sigma(V)=\int_{S^{n-1}}|V|^{2}d\sigma(V)=\omega_{n}$ for each $i$.

In this way we see that the Ricci $2$-tensor $\operatorname{Ric}$ is an
average of the Riemann curvature $4$-tensor $\operatorname{Rm}$, since
$\operatorname{Ric}=\operatorname{tr}_{1,4}\operatorname{Rm}$. More
geometrically, the Ricci curvature of a line $L$ in $T_{x}M$ is the average of
all sectional curvatures of $2$-planes in $T_{x}M$ containing $L$. Similarly,
the scalar curvature function $R$ is the average of all Ricci curvatures of
lines in $T_{x}M$.

Another way the trace enters is: For a family of
invertible square matrices $A(t)$ we have Jacobi's formula: $\frac{d}{dt}\det
A=\det A\operatorname{tr}(A^{-1}\frac{dA}{dt})$ (using Cramer's rule). Since
the Riemannian measure is $d\mu_{g}=\sqrt{\det g_{ij}}dx^{1}\cdots dx^{n}$, if
we vary a metric by $\frac{\partial}{\partial s}g=v$, then its measure varies
by $\frac{\partial}{\partial s}d\mu_{g}=\frac{\operatorname{tr}_{g}v}{2}
d\mu_{g}$.

The covariant derivative takes a degree $r$ tensor $T$ to the degree $r+1$
tensor $\nabla T$. By tracing we have a differential operator that decreases
the degree by $1$: The divergence is $\operatorname{div}T=\operatorname{tr}
_{1,2}\nabla T$. Tracing also allows us to average the Hessian: The (rough)
Laplacian of $T$ is $\Delta T=\operatorname{tr}_{1,2}\nabla^{2}T$. Another
example is: If $v=\mathcal{L}_{X}g$, then $\frac{\operatorname{tr}_{g}v}
{2}=\operatorname{div}X$.

The trace also arises when considering the irreducible decomposition of a
tensor. For example, given a symmetric $2$-tensor $\beta$, we may write
$\beta=(\beta-\frac{1}{n}(\operatorname{tr}_{g}\beta)g)+\frac{1}
{n}(\operatorname{tr}_{g}\beta)g$. Here, the norm of the trace-free part
$|\beta-\frac{1}{n}(\operatorname{tr}_{g}\beta)g|$ is a measure of how far
$\beta$ is from a multiple of $g$. If $\beta=\operatorname{Ric}$ and $n\geq3$,
then its trace-free part is zero iff $g$ is Einstein.