[guided]The martingale increment compares what we know after seeing $X_i$ with what we knew just before seeing $X_i$. To make this comparison concrete, we write both conditional expectations as ordinary integrals.
For each coordinate $j$, define the law
\begin{align*}
\mu_j:=\mathbb P\circ X_j^{-1}.
\end{align*}
Because $X_1,\dots,X_n$ are independent, the law of the full random vector $(X_1,\dots,X_n)$ is the product measure
\begin{align*}
\mu_1\otimes\cdots\otimes\mu_n.
\end{align*}
Fix $i\in\{1,\dots,n\}$. The future variables are $X_{i+1},\dots,X_n$, so define their product law by
\begin{align*}
\nu_i:=\mu_{i+1}\otimes\cdots\otimes\mu_n,
\end{align*}
with the convention that when $i=n$, this is the probability measure on a one-point space.
Now define the map $g_i:\mathcal X_1\times\cdots\times\mathcal X_i\to\mathbb R$ for $\mu_1\otimes\cdots\otimes\mu_i$-almost every $(x_1,\dots,x_i)$ by
\begin{align*}
g_i(x_1,\dots,x_i):=\int_{\mathcal X_{i+1}\times\cdots\times\mathcal X_n} f(x_1,\dots,x_i,y_{i+1},\dots,y_n)\,d\nu_i(y_{i+1},\dots,y_n).
\end{align*}
This is the expected value of $f$ after fixing the first $i$ coordinates and averaging over the independent future coordinates. The integrability hypothesis on $Z=f(X_1,\dots,X_n)$ says exactly that
\begin{align*}
\int_{\mathcal X_1\times\cdots\times\mathcal X_n} |f(x_1,\dots,x_n)|\,d(\mu_1\otimes\cdots\otimes\mu_n)(x_1,\dots,x_n)<\infty.
\end{align*}
Therefore Tonelli's theorem applied to $|f|$ implies that the future integral defining $g_i$ is finite for $\mu_1\otimes\cdots\otimes\mu_i$-almost every fixed past-and-present tuple.
We verify that $g_i(X_1,\dots,X_i)$ is the conditional expectation of $Z$ given $\mathcal F_i$. Let $\varphi:\mathcal X_1\times\cdots\times\mathcal X_i\to\mathbb R$ be bounded and measurable. Since $\varphi(X_1,\dots,X_i)$ is $\mathcal F_i$-measurable, the defining identity for conditional expectation requires
\begin{align*}
\mathbb E[\varphi(X_1,\dots,X_i)Z]=\mathbb E[\varphi(X_1,\dots,X_i)g_i(X_1,\dots,X_i)].
\end{align*}
Using the product law of $(X_1,\dots,X_n)$, the left-hand side is
\begin{align*}
\int_{\mathcal X_1\times\cdots\times\mathcal X_n} \varphi(x_1,\dots,x_i)f(x_1,\dots,x_n)\,d(\mu_1\otimes\cdots\otimes\mu_n)(x_1,\dots,x_n).
\end{align*}
[Fubini's theorem](/theorems/2961) applies because $\varphi$ is bounded and $f$ is integrable under the product law. Integrating first over the future coordinates gives
\begin{align*}
\int_{\mathcal X_1\times\cdots\times\mathcal X_i} \varphi(x_1,\dots,x_i)g_i(x_1,\dots,x_i)\,d(\mu_1\otimes\cdots\otimes\mu_i)(x_1,\dots,x_i),
\end{align*}
which equals
\begin{align*}
\mathbb E[\varphi(X_1,\dots,X_i)g_i(X_1,\dots,X_i)].
\end{align*}
Thus
\begin{align*}
M_i=\mathbb E[Z\mid\mathcal F_i]=g_i(X_1,\dots,X_i)
\end{align*}
almost surely.
Before revealing $X_i$, we average this same function over the possible values of $X_i$. Define the map $h_i:\mathcal X_1\times\cdots\times\mathcal X_{i-1}\to\mathbb R$ by
\begin{align*}
h_i(x_1,\dots,x_{i-1}):=\int_{\mathcal X_i}g_i(x_1,\dots,x_{i-1},u)\,d\mu_i(u).
\end{align*}
The same testing argument, now with bounded [measurable functions](/page/Measurable%20Functions) of $(X_1,\dots,X_{i-1})$, proves that
\begin{align*}
M_{i-1}=\mathbb E[Z\mid\mathcal F_{i-1}]=h_i(X_1,\dots,X_{i-1})
\end{align*}
almost surely. This representation is the key reduction: the martingale increment is now a pointwise difference between a function value and its average over the $i$-th coordinate.[/guided]