[proofplan]
We reduce the assertion to the corresponding factorization of an integral over a product probability measure. First we set $Y_i=g_i(X_i)$ and prove directly from the definition of independence that the real-valued random variables $Y_1,\dots,Y_n$ are independent. Their joint law is therefore the product of their marginal laws, so the expectation of $\prod_i Y_i$ becomes the integral of the coordinate product function against a product measure. Finally, the Tonelli-[Fubini theorem](/theorems/513) factors that product integral into the product of the one-dimensional expectations.
[/proofplan]
[step:Pass from the original variables to measurable real-valued variables]
For each $i \in \{1,\dots,n\}$, define the map
\begin{align*}Y_i:(\Omega,\mathcal F)\to(\mathbb R,\mathcal B(\mathbb R)), \quad \omega \mapsto g_i(X_i(\omega))\end{align*}
Since $X_i$ is $(\mathcal F,\mathcal E_i)$-measurable and $g_i$ is $(\mathcal E_i,\mathcal B(\mathbb R))$-measurable, the composition $Y_i=g_i\circ X_i$ is $(\mathcal F,\mathcal B(\mathbb R))$-measurable. Thus each $Y_i$ is a real-valued [random variable](/page/Random%20Variable). By hypothesis, every $Y_i$ is integrable and the product random variable $\prod_{i=1}^n Y_i$ is integrable.
[/step]
[step:Show that the measurable transforms remain independent]
Let $B_1,\dots,B_n \in \mathcal B(\mathbb R)$ be Borel sets. For each $i \in \{1,\dots,n\}$, define the event
\begin{align*}
A_i := Y_i^{-1}(B_i)=X_i^{-1}(g_i^{-1}(B_i)) \in \mathcal F.
\end{align*}
Because $g_i$ is measurable, $g_i^{-1}(B_i)\in\mathcal E_i$. Since $X_1,\dots,X_n$ are independent, the events $X_i^{-1}(g_i^{-1}(B_i))$ satisfy
\begin{align*}
\mathbb P\left(\bigcap_{i=1}^n A_i\right)=\prod_{i=1}^n \mathbb P(A_i).
\end{align*}
Equivalently,
\begin{align*}
\mathbb P(Y_1\in B_1,\dots,Y_n\in B_n)=\prod_{i=1}^n \mathbb P(Y_i\in B_i).
\end{align*}
This is exactly the independence of $Y_1,\dots,Y_n$.
[guided]
The point of this step is that independence is stable under applying [measurable functions](/page/Measurable%20Functions) separately to the independent variables. We verify this from the definition, rather than treating it as a black box.
Fix Borel sets $B_1,\dots,B_n \in \mathcal B(\mathbb R)$. For each $i \in \{1,\dots,n\}$, define
\begin{align*}
A_i := Y_i^{-1}(B_i)=\{\omega\in\Omega:Y_i(\omega)\in B_i\}.
\end{align*}
Since $Y_i=g_i\circ X_i$, this event can be rewritten as
\begin{align*}
A_i=X_i^{-1}(g_i^{-1}(B_i)).
\end{align*}
The set $g_i^{-1}(B_i)$ belongs to $\mathcal E_i$ because $g_i:(E_i,\mathcal E_i)\to(\mathbb R,\mathcal B(\mathbb R))$ is measurable. Therefore $A_i\in\mathcal F$ because $X_i:(\Omega,\mathcal F)\to(E_i,\mathcal E_i)$ is measurable.
Now we use independence of the original random variables. Since $g_i^{-1}(B_i)\in\mathcal E_i$ for each $i$, the defining property of independence of $X_1,\dots,X_n$ gives
\begin{align*}
\mathbb P\left(\bigcap_{i=1}^n X_i^{-1}(g_i^{-1}(B_i))\right)=\prod_{i=1}^n \mathbb P\left(X_i^{-1}(g_i^{-1}(B_i))\right).
\end{align*}
Using the identity $A_i=X_i^{-1}(g_i^{-1}(B_i))$, this becomes
\begin{align*}
\mathbb P\left(\bigcap_{i=1}^n A_i\right)=\prod_{i=1}^n \mathbb P(A_i).
\end{align*}
Since the Borel sets $B_1,\dots,B_n$ were arbitrary, this proves that $Y_1,\dots,Y_n$ are independent real-valued random variables.
[/guided]
[/step]
[step:Identify the joint law with the product of the marginal laws]
Define the joint random vector
\begin{align*}Y:(\Omega,\mathcal F)\to(\mathbb R^n,\mathcal B(\mathbb R^n)), \quad \omega \mapsto (Y_1(\omega),\dots,Y_n(\omega))\end{align*}
Let $\mu$ denote the law of $Y$, so $\mu:=\mathbb P\circ Y^{-1}$ on $(\mathbb R^n,\mathcal B(\mathbb R^n))$. For each $i\in\{1,\dots,n\}$, let $\mu_i$ denote the law of $Y_i$, so $\mu_i:=\mathbb P\circ Y_i^{-1}$ on $(\mathbb R,\mathcal B(\mathbb R))$.
For every rectangle $B_1\times\cdots\times B_n$ with $B_i\in\mathcal B(\mathbb R)$, independence of $Y_1,\dots,Y_n$ gives
\begin{align*}
\mu(B_1\times\cdots\times B_n)=\prod_{i=1}^n\mu_i(B_i).
\end{align*}
The collection of rectangles $B_1\times\cdots\times B_n$, with $B_i\in\mathcal B(\mathbb R)$, is a $\pi$-system because finite intersections are again rectangles. It generates $\mathcal B(\mathbb R^n)$, since the [product topology](/page/Product%20Topology) on $\mathbb R^n$ has a countable basis of open rectangles with rational endpoints, and these rectangles generate the Borel $\sigma$-algebra. Both $\mu$ and $\mu_1\otimes\cdots\otimes\mu_n$ are probability measures. By the uniqueness theorem for finite measures that agree on a generating $\pi$-system, we have
\begin{align*}
\mu=\mu_1\otimes\cdots\otimes\mu_n.
\end{align*}
[/step]
[step:Rewrite the expectation as an integral over the product law]
Define the coordinate product function
\begin{align*}
h:\mathbb R^n\to\mathbb R, \quad y\mapsto \prod_{i=1}^n y_i,
\end{align*}
where $y=(y_1,\dots,y_n)\in\mathbb R^n$. The function $h$ is Borel measurable because it is a finite product of coordinate functions. Also
\begin{align*}
h(Y(\omega))=\prod_{i=1}^n Y_i(\omega)
\end{align*}
for every $\omega\in\Omega$. By the definition of pushforward measure and expectation,
\begin{align*}
\mathbb E\left[\prod_{i=1}^n Y_i\right]=\int_\Omega h(Y(\omega))\,d\mathbb P(\omega)=\int_{\mathbb R^n} h(y)\,d\mu(y).
\end{align*}
Since $\prod_{i=1}^n Y_i$ is integrable by hypothesis, the function $h$ is $\mu$-integrable. Using $\mu=\mu_1\otimes\cdots\otimes\mu_n$, this becomes
\begin{align*}
\mathbb E\left[\prod_{i=1}^n Y_i\right]=\int_{\mathbb R^n}\prod_{i=1}^n y_i\,d(\mu_1\otimes\cdots\otimes\mu_n)(y).
\end{align*}
[/step]
[step:Factor the product integral by iterating Fubini]
For each $i\in\{1,\dots,n\}$, the integrability of $Y_i$ gives
\begin{align*}
\int_{\mathbb R}|t|\,d\mu_i(t)=\mathbb E[|Y_i|]<\infty.
\end{align*}
The preceding step shows that the coordinate product function $h:\mathbb R^n\to\mathbb R$ is integrable with respect to $\mu_1\otimes\cdots\otimes\mu_n$. Therefore the signed Fubini theorem applies to the finite product [measure space](/page/Measure%20Space) $(\mathbb R^n,\mathcal B(\mathbb R^n),\mu_1\otimes\cdots\otimes\mu_n)$.
For $k\in\{1,\dots,n\}$, define the partial product function $h_k:\mathbb R^k\to\mathbb R$ by
\begin{align*}
h_k(t_1,\dots,t_k):=\prod_{i=1}^k t_i.
\end{align*}
We prove by induction on $k$ that
\begin{align*}
\int_{\mathbb R^k} h_k(t_1,\dots,t_k)\,d(\mu_1\otimes\cdots\otimes\mu_k)(t_1,
\dots,t_k)=\prod_{i=1}^k\int_{\mathbb R} t\,d\mu_i(t).
\end{align*}
For $k=1$ this is the definition of $h_1$. Assume the identity holds for $k-1$, where $2\le k\le n$. Since $h_k=h_{k-1}\cdot t_k$ and $h_k$ is integrable with respect to $\mu_1\otimes\cdots\otimes\mu_k$, the signed Fubini theorem gives
\begin{align*}
\int_{\mathbb R^k} h_k\,d(\mu_1\otimes\cdots\otimes\mu_k)=\int_{\mathbb R}\left(\int_{\mathbb R^{k-1}} h_{k-1}(t_1,\dots,t_{k-1})t_k\,d(\mu_1\otimes\cdots\otimes\mu_{k-1})(t_1,
\dots,t_{k-1})\right)d\mu_k(t_k).
\end{align*}
For fixed $t_k\in\mathbb R$, the factor $t_k$ is constant with respect to the measure $\mu_1\otimes\cdots\otimes\mu_{k-1}$, so linearity of the integral gives
\begin{align*}
\int_{\mathbb R^{k-1}} h_{k-1}(t_1,\dots,t_{k-1})t_k\,d(\mu_1\otimes\cdots\otimes\mu_{k-1})(t_1,
\dots,t_{k-1})=t_k\int_{\mathbb R^{k-1}}h_{k-1}\,d(\mu_1\otimes\cdots\otimes\mu_{k-1}).
\end{align*}
Using the induction hypothesis, the right-hand side becomes
\begin{align*}
t_k\prod_{i=1}^{k-1}\int_{\mathbb R}t\,d\mu_i(t).
\end{align*}
The constant $\prod_{i=1}^{k-1}\int_{\mathbb R}t\,d\mu_i(t)$ is finite because each $Y_i$ is integrable. Pulling this constant outside the remaining integral gives
\begin{align*}
\int_{\mathbb R^k} h_k\,d(\mu_1\otimes\cdots\otimes\mu_k)=\prod_{i=1}^{k}\int_{\mathbb R}t\,d\mu_i(t).
\end{align*}
The induction proves the formula for $k=n$, hence
\begin{align*}
\int_{\mathbb R^n}\prod_{i=1}^n y_i\,d(\mu_1\otimes\cdots\otimes\mu_n)(y)=\prod_{i=1}^n\int_{\mathbb R}t\,d\mu_i(t).
\end{align*}
For each $i$, the definition of the law $\mu_i=\mathbb P\circ Y_i^{-1}$ gives
\begin{align*}
\int_{\mathbb R}t\,d\mu_i(t)=\int_\Omega Y_i(\omega)\,d\mathbb P(\omega)=\mathbb E[Y_i].
\end{align*}
Combining these identities yields
\begin{align*}
\mathbb E\left[\prod_{i=1}^n Y_i\right]=\prod_{i=1}^n\mathbb E[Y_i].
\end{align*}
Finally, since $Y_i=g_i(X_i)$ for each $i$, we obtain
\begin{align*}
\mathbb E\left[\prod_{i=1}^n g_i(X_i)\right]=\prod_{i=1}^n\mathbb E[g_i(X_i)].
\end{align*}
This is the desired factorization.
[/step]