[proofplan]
The proof is the Chern-Weil interpretation of Gauss-Bonnet. First we view the oriented tangent bundle with its Riemannian metric as an oriented Euclidean vector bundle and apply the Pfaffian Chern-Weil theorem to identify the Euler form with the real de Rham representative of the integral Euler class. Then we use the de Rham integration pairing to convert the integral of this representative into the evaluation of $e(TM)$ on the fundamental class of $M$. Finally, the [Euler class evaluation formula for the tangent bundle](/theorems/9787) identifies this number with the Euler characteristic.
[/proofplan]
[step:Identify the Euler form with the Chern-Weil representative of $e(TM)$]
Since $(M,g)$ is a closed oriented smooth Riemannian manifold of dimension $2m$, the tangent bundle $TM\to M$ is an oriented smooth real vector bundle of rank $2m$, and $g$ is a bundle metric on $TM$. Let
\begin{align*}
P_{SO}(TM,g)\to M
\end{align*}
denote the principal $SO(2m)$-bundle of positive oriented $g$-orthonormal frames. The Levi-Civita connection $\nabla^{TM}$ induces a principal $SO(2m)$-connection on $P_{SO}(TM,g)$, and its curvature is the curvature used in the normalized Pfaffian definition of the Euler form $e(\nabla^{TM})$.
By [citetheorem:9774], applied to the oriented Euclidean vector bundle $(TM,g)$ and to the Levi-Civita connection, the Pfaffian Chern-Weil form $e(\nabla^{TM})$ is closed and represents the image of the integral Euler class $e(TM)\in H^{2m}(M;\mathbb Z)$ in $H^{2m}_{\mathrm{dR}}(M)$. Thus
\begin{align*}
[e(\nabla^{TM})]_{\mathrm{dR}}=\rho(e(TM)),
\end{align*}
where $\rho:H^{2m}(M;\mathbb Z)\to H^{2m}_{\mathrm{dR}}(M)$ denotes the coefficient-comparison map followed by the de Rham comparison isomorphism.
[/step]
[step:Convert the integral of the Euler form into evaluation on the fundamental class]
Let $[M]\in H_{2m}(M;\mathbb Z)$ be the fundamental class determined by the given orientation of $M$, and let $[M]_{\mathbb R}\in H_{2m}(M;\mathbb R)$ be its image under the coefficient homomorphism. Let $\iota:\mathbb Z\to\mathbb R$ denote the standard inclusion. Since $e(\nabla^{TM})=E_g\operatorname{vol}_g$, the de Rham integration pairing evaluates this closed top-degree form as
\begin{align*}
\int_M E_g\,d\operatorname{vol}_g.
\end{align*}
The compatibility of the de Rham comparison map with the singular evaluation pairing gives
\begin{align*}
\int_M E_g\,d\operatorname{vol}_g=\langle \rho(e(TM)),[M]_{\mathbb R}\rangle_{\mathbb R}.
\end{align*}
Using the equality $[e(\nabla^{TM})]_{\mathrm{dR}}=\rho(e(TM))$ from the previous step, this is
\begin{align*}
\int_M E_g\,d\operatorname{vol}_g=\iota\bigl(\langle e(TM),[M]\rangle_{\mathbb Z}\bigr).
\end{align*}
[guided]
The point of this step is to pass from a differential form integral to a topological evaluation. Let $[M]\in H_{2m}(M;\mathbb Z)$ denote the fundamental class determined by the orientation of the closed manifold $M$, and let $[M]_{\mathbb R}\in H_{2m}(M;\mathbb R)$ be its image under extension of coefficients. Let $\iota:\mathbb Z\to\mathbb R$ denote the standard inclusion. Because $M$ has no boundary and is compact, integration of top-degree forms over $M$ defines the standard de Rham pairing with $[M]_{\mathbb R}$.
We apply this pairing to the closed form $e(\nabla^{TM})\in\Omega^{2m}(M)$. By the statement notation, $e(\nabla^{TM})=E_g\operatorname{vol}_g$, so its de Rham integral is the measure integral
\begin{align*}
\int_M E_g\,d\operatorname{vol}_g.
\end{align*}
The previous step proved that its de Rham class is the image of the integral Euler class:
\begin{align*}
[e(\nabla^{TM})]_{\mathrm{dR}}=\rho(e(TM)).
\end{align*}
The compatibility of the de Rham comparison map with evaluation on the fundamental class says that, for any integral cohomology class $\alpha\in H^{2m}(M;\mathbb Z)$ represented in de Rham cohomology by $\rho(\alpha)$, integration of any closed form representing $\rho(\alpha)$ equals the real evaluation of $\rho(\alpha)$ on $[M]_{\mathbb R}$, which is the image under $\iota$ of the integral singular cohomology evaluation of $\alpha$ on $[M]$. Taking $\alpha=e(TM)$ gives
\begin{align*}
\int_M E_g\,d\operatorname{vol}_g=\langle \rho(e(TM)),[M]_{\mathbb R}\rangle_{\mathbb R}=\iota\bigl(\langle e(TM),[M]\rangle_{\mathbb Z}\bigr).
\end{align*}
This is exactly the bridge we need: the left-hand side is the geometric curvature integral written with the Riemannian volume measure, while the right-hand side is the Euler number of the tangent bundle viewed as a real number.
[/guided]
[/step]
[step:Evaluate the tangent bundle Euler class as the Euler characteristic]
The hypotheses of [citetheorem:9787] are satisfied because $M$ is a closed oriented smooth manifold of dimension $2m$, and $TM\to M$ is its oriented tangent bundle. Therefore
\begin{align*}
\langle e(TM),[M]\rangle_{\mathbb Z}=\chi(M).
\end{align*}
Combining this equality with the identity from the previous step, and viewing the integer $\chi(M)$ as a real number under $\iota:\mathbb Z\to\mathbb R$, gives
\begin{align*}
\int_M E_g\,d\operatorname{vol}_g=\chi(M).
\end{align*}
Together with the Chern-Weil representative statement already proved in the first step, this proves the theorem.
[/step]