[guided]The point of introducing $H$ is to turn the [random variable](/page/Random%20Variable) $Z$ into a two-variable indicator. Define
\begin{align*}
H:\Omega\times[0,\infty)&\to[0,\infty)
\end{align*}
\begin{align*}
(\omega,u)&\mapsto \mathbb 1_{\{Z>u\}}(\omega).
\end{align*}
Before applying Tonelli's theorem, we verify its measurability hypothesis. The set on which $H$ equals $1$ is
\begin{align*}
\{(\omega,u)\in\Omega\times[0,\infty):H(\omega,u)=1\}
=
\{(\omega,u)\in\Omega\times[0,\infty):u<Z(\omega)\}.
\end{align*}
The coordinate projection
\begin{align*}
\pi_2:\Omega\times[0,\infty)&\to[0,\infty)
\end{align*}
\begin{align*}
(\omega,u)&\mapsto u
\end{align*}
is $\mathcal F\otimes\mathcal B([0,\infty))$-measurable, and the composition
\begin{align*}
Z\circ\pi_1:\Omega\times[0,\infty)&\to[0,\infty)
\end{align*}
with the first coordinate projection $\pi_1:\Omega\times[0,\infty)\to\Omega$ is also measurable. Hence the map
\begin{align*}
G:\Omega\times[0,\infty)&\to\mathbb R
\end{align*}
\begin{align*}
(\omega,u)&\mapsto Z(\omega)-u
\end{align*}
is measurable, and the preceding superlevel set is $G^{-1}((0,\infty))$. Since $(0,\infty)$ is Borel in $\mathbb R$, this proves that $H$ is $\mathcal F\otimes\mathcal B([0,\infty))$-measurable.
For fixed $\omega\in\Omega$, the function $u\mapsto H(\omega,u)$ equals $1$ exactly for those levels $u$ below $Z(\omega)$ and equals $0$ above that level. Therefore
\begin{align*}
\int_0^\infty H(\omega,u)\,d\mathcal L^1(u)=\mathcal L^1([0,Z(\omega)))=Z(\omega).
\end{align*}
We now want to integrate this identity over $\Omega$. The integrand $H$ is nonnegative, so Tonelli's theorem applies without any prior integrability assumption. This is the reason the identity is valid even when $\mathbb E[Z]=+\infty$. We obtain
\begin{align*}
\mathbb E[Z]
=
\int_\Omega\left(\int_0^\infty H(\omega,u)\,d\mathcal L^1(u)\right)d\mathbb P(\omega).
\end{align*}
Tonelli's theorem permits the order of integration to be exchanged:
\begin{align*}
\mathbb E[Z]
=
\int_0^\infty\left(\int_\Omega H(\omega,u)\,d\mathbb P(\omega)\right)d\mathcal L^1(u).
\end{align*}
For each fixed $u\in[0,\infty)$, the inner integral is the expectation of the indicator of the event $\{Z>u\}$:
\begin{align*}
\int_\Omega H(\omega,u)\,d\mathbb P(\omega)
=
\int_\Omega \mathbb 1_{\{Z>u\}}(\omega)\,d\mathbb P(\omega)
=
\mathbb P(Z>u).
\end{align*}
Substituting this into the previous display gives
\begin{align*}
\mathbb E[Z]=\int_0^\infty \mathbb P(Z>u)\,d\mathcal L^1(u).
\end{align*}
The equality is an equality of extended nonnegative quantities, so no finite-expectation assumption is being hidden.[/guided]