TITLE: What is the motivation to build measure theory?
QUESTION [6 upvotes]: I started reading about measure theory on wikipedia, and downloaded some PDFs, but they all start defining things that I can understand, but can't imagine the motivation to define these things. 
'Integration theory' started with the desire to find the area of graphs by a process of infintie summation. 
With this analogy, what were mathematicians expecting to create when defining metric spaces and other things related to it? What's the central problem that created all this?
I'm trying to understand Lebesgue integration but the article starts with these metric spaces definitions...

REPLY [4 votes]: One of the primary motivations (there are many, I'm sure) for developing measure theory has to do with the failure of the theory of Riemann integration to behave nicely under taking pointwise limits of functions. In particular, it is well-known that pointwise convergence of a sequence of functions does not translate to the interchange of limits and integrals; for example, if
$$
f_n(x) = 
\begin{cases}
1 & x\in[n,n+1]\\
0 & \text{otherwise}
\end{cases}
$$
then as $n\to\infty$, $f_n$ converges pointwise to the zero function. If we take its integral,
$$
\int_{-\infty}^\infty f_n(x)~dx = 1,
$$
which leads to
$$
\lim_{n\to\infty} \int_{-\infty}^\infty f_n(x)~dx  = 1 \neq 0 = \int_{-\infty}^\infty \lim_{n\to\infty} f_n(x)~dx.
$$
This inability to interchange a limit and an integral can be extremely inconvenient. One can interchange a limit and a Riemann integration under certain circumstances like uniform convergence, but this is usually far too restrictive of a condition. What measure-theoretic integration gives you is a way to do this interchange provided you have pointwise convergence and much weaker conditions than uniform convergence; in exchange, it forces you to throw out sets of measure zero. In addition, once the theory is developed you suddenly have extremely powerful tools to take limits of integrals you did not have before (e.g. Lebesgue dominated convergence theorem).
This simplification of the issue of convergence of integrals then allows one to make the great shift in analytical thinking of considering metric spaces of functions that are nicely behaved with respect to integration, in the sense that they are complete under an appropriately defined integral norm. Function spaces had been around (the continuous functions under supremum norm), but before measure theory it was not possible to precisely define a norm on a function space using an integral (at best one could define a seminorm). With measure theory, analysis drifted away from the study of functions and their continuity/differentiability properties and toward the study of function spaces.
This shift in ideas presided over decades of major mathematical and scientific change, leading to the notion of a Hilbert and Banach space and becoming deeply intertwined with the emerging field of quantum mechanics. It allowed mathematicians to introduce the tools of linear algebra to analysis (which today we call functional analysis) and look at inherently infinite-dimensional problems (such as PDEs) in a concrete framework. Today function spaces remain a central element of the toolbox of virtually all mathematicians, and measure theory is at the heart of its foundation.
If this doesn't motivate measure theory for you, then virtually nothing will :)