[guided]The conceptual heart of the proof is that the Lebesgue integral is insensitive to what happens on null sets. The hypothesis "$Z \geq 0$ $\mathbb{P}$-a.s." says that $Z$ is non-negative everywhere except on a set of probability zero, and we want to conclude $\mathbb{E}[Z] \geq 0$. The challenge is that the Lebesgue integral is defined over all of $\Omega$, so we must show the "bad" set $N = \{Z < 0\}$ contributes nothing.
**Setting up the decomposition.** Define
\begin{align*}
Z^+ := \max(Z, 0) : \Omega \to [0, \infty), \qquad Z^- := \max(-Z, 0) : \Omega \to [0, \infty).
\end{align*}
Both are $\mathcal{F}$-measurable (compositions of the measurable function $Z$ with the continuous maps $t \mapsto \max(t,0)$ and $t \mapsto \max(-t,0)$). They satisfy $Z = Z^+ - Z^-$, and by the definition of the Lebesgue integral for signed integrable functions:
\begin{align*}
\mathbb{E}[Z] = \int_\Omega Z^+ \, d\mathbb{P} - \int_\Omega Z^- \, d\mathbb{P}.
\end{align*}
The hypothesis $Z \geq 0$ $\mathbb{P}$-a.s. means the null set $N := \{Z < 0\}$ satisfies $\mathbb{P}(N) = 0$. Crucially, $\{Z^- > 0\} = \{-Z > 0\} = \{Z < 0\} = N$, so $Z^-$ is strictly positive only inside $N$; outside $N$, $Z^- = 0$ identically.
**Why does a function supported on a null set integrate to zero?** The Lebesgue integral $\int_\Omega Z^- \, d\mathbb{P}$ is defined as
\begin{align*}
\int_\Omega Z^- \, d\mathbb{P} = \sup\!\left\{\int_\Omega \phi \, d\mathbb{P} : \phi \text{ is } \mathcal{F}\text{-simple}, \; 0 \leq \phi \leq Z^-\right\}.
\end{align*}
Take any such simple function $\phi = \sum_{k=1}^m c_k \mathbf{1}_{E_k}$ with $E_k \in \mathcal{F}$ pairwise disjoint and $c_k \geq 0$. For any $\omega \notin N$, we have $Z^-(\omega) = 0$, so the bound $\phi(\omega) \leq Z^-(\omega) = 0$ together with $\phi \geq 0$ forces $\phi(\omega) = 0$. This means each indicator $\mathbf{1}_{E_k}$ must vanish outside $N$, i.e., $E_k \subseteq N$. By monotonicity of the measure $\mathbb{P}$:
\begin{align*}
\mathbb{P}(E_k) \leq \mathbb{P}(N) = 0.
\end{align*}
Therefore every simple function $\phi \leq Z^-$ integrates to
\begin{align*}
\int_\Omega \phi \, d\mathbb{P} = \sum_{k=1}^m c_k \mathbb{P}(E_k) = 0.
\end{align*}
Since every approximant achieves the value $0$, the supremum is $0$: $\int_\Omega Z^- \, d\mathbb{P} = 0$.
**Why is $\int_\Omega Z^+ \, d\mathbb{P} \geq 0$?** The integral is the supremum of values $\sum_k c_k \mathbb{P}(E_k)$, each of which is $\geq 0$ (since $c_k \geq 0$ and $\mathbb{P}(E_k) \geq 0$). The supremum of a set of non-negative numbers is non-negative.
**Conclusion.** Combining:
\begin{align*}
\mathbb{E}[Z] = \int_\Omega Z^+ \, d\mathbb{P} - \underbrace{\int_\Omega Z^- \, d\mathbb{P}}_{=\,0} = \int_\Omega Z^+ \, d\mathbb{P} \geq 0.
\end{align*}
The lesson: null sets are invisible to the Lebesgue integral, so "$Z \geq 0$ a.s." is just as good as "$Z \geq 0$ everywhere" for the purpose of integration.[/guided]