# Motivation for Definition of Measurable Function

I'm having trouble understanding why a function is defined as "measurable" if the preimage of every measurable set is measurable. I see the parallel to the definition of continuity, and the latter definition seems sensible to me. What I don't understand is why we should take this parallel as the defining property of a "measurable function."

Can somebody please motivate this definition for me?

In order to integrate a function $f:X\to \mathbb R$ we have to approximate it by easy-to-integrate simple functions of the form $\sum_{i=1}^N c_i \chi_{A_i}$ where $c_i$ are constants and $A_i$ are measurable sets. Then the integral of this simple function is equal to $\sum_{i=1}^N c_i \mu(A_i)$. It is similar to the definition of the Riemann integral, where we use step functions there, instead of simple functions, since $A_i$ are taken to be intervals, rather than arbitrary measurable sets.
In order to approximate the integral of $f$ by those easy-to-integrate functions we have to require that it is measurable, in the sense that the preimage of open sets of $\mathbb R$ are measurable subsets of $X$. In fact, this is how we define $\int_X fd\mu$. If $f\geq 0$ we define $$\int_X fd\mu= \sup \{ \int_X sd\mu: 0\leq s\leq f \textrm { and s is simple}\}$$
In particular, we can find a sequence of simple functions $s_n$ converging pointwise almost everywhere to $f$ (that needs some work to prove), such that $\int s_n$ converges to $\int f$.