# Measure theory: motivation behind monotone convergence theorem

I am watching a very nice set of videos on measure theory, which are great. But I am not clear on what the motivation is behind the monotone convergence theorem--meaning why we need it?

The statement of the theorem is that given a set of functions $$\\{f_n\\} \rightarrow f$$ such that $$f_1 \leq f_2 \leq f_3 \leq ... f_n \leq f$$

$$\lim_{n \rightarrow \infty} \int_X f_n d\mu = \int_X \lim_{n \rightarrow \infty } f_n d\mu = \int_X f d\mu$$

So the theorem suggests the interchange of the limit and the integral sign. But I am not sure what the implications of this interchange is and under what conditions this interchange is not possible (for the Lebesgue integral)? Meaning, that this particular theorem of monotone convergence presupposes the Lebesgue integral as opposed to the Riemann integral. So, is monotone convergence not guaranteed for the Riemann integral--is that the key distinction? And second, are the cases where monotone convergence fails for the Riemann integral due to the fact that the Riemann integral gives mass to sets in $$X$$ of measure zero, while the Lebesgue integral does not have this problem?

Here's a simple example where the monotone convergence theorem fails for the Riemann integral. Fix an enumeration $$(q_k)_{k\in\mathbb N}$$ of the rational numbers in the interval $$[0,1]$$. Define $$f_n(x)$$ to equal $$1$$ for $$x=q_0,q_1,\dots, q_n$$ and to equal $$0$$ for all other $$x\in[0,1]$$. Then the sequence of functions $$(f_n)$$ converges monotonically pointwise to the characteristic function of $$\mathbb Q\cap[0,1]$$, which is not Riemann integrable on $$[0,1]$$, even though each $$f_n$$ is Riemann integrable with integral $$0$$.
The Monotone convergence theorem requires the sequence of measurable functions to be non-negative. One can consider the function $$f_n(x) = -|x|/n$$. For Riemann integral, you can move the limit inside if $$f_n \to f$$ uniformly and the integrand is finite. You can consider the Monotone Convergence Theorem as a tool to move the limit inside the integral with given conditions.