What is a "measurable function" in laymen words? (Edit: from a real analysis view) Wikipedia mentions

In mathematics and in particular measure theory, a measurable function is a function between the underlying sets of two measurable spaces that preserves the structure of the spaces: the preimage of any measurable set is measurable, analogous to the definition that a function between topological spaces is continuous if it preserves the topological structure: the preimage of each open set is open. 

However, this is not intuitive/understandable enough for someone who does not have the background in measure theory and real analysis. (For example questions below arise: What is an underlying set of measurable spaces? or What is a measurable set?)
Considering this, can someone please explain, in easy words, what kind of functions are measurable and what kinds are not? Some examples of both sides and highlighting the main characteristic of such functions could be helpful. Being very precise is not the goal here.
 A: As has been commented, a measurable space is a set together with a collection of subsets that are declared measurable.  If that sounds a bit arbitrary, it's because it is; it's not without precedent however since a topological space is a set together with a collection of sets that are declared open.  The thing is, is that this is the simplest structure you can impose and get a rich and meaningful theory out of it -- which might seem a bit surprising when you consider how little was said.
We add more structure by defining a measure: this is a function that assigns a number to a measurable set.  It has to follow two rules (always; these are axioms, or unbreakable rules):


*

*The empty set is assigned the value $0$ (which makes sense, the empty set is, in layman's terms, "nothing")

*The whole is never less than the sum of the parts: if you take three sets and measure them and add their measures together, then the value you get is not less than what you get by measuring all three sets as though they were one.  This is called subadditivity.


A measurable function is one that preserves measurable sets: i.e. if $f$ is a measurable function, and you have a measurable set $f(B)$ then it must always be the case that the set of all points that $f$ maps into $f(B)$ is measurable as well.  (That's what the quote you provide is talking about when it mentions pre-images).  The guarantee is that if you have a measurable set given by $f$ then it came from a measurable set to begin with.
So what do measurable sets and functions look like?  Some examples:


*

*Let $X$ be a finite set, say $\{0,1,2,3,4,5,6,7,8,9\}$ and let every subset of $X$ be measurable (then $X$ has a discrete measure structure).  We define $f$ as counting measure: $f(A) = \#A$ so that $f$ counts the number of elements in the set $A\subseteq X$.

*Take all rectangles in ${\mathbb R}^2$ and define $f(R) = $width$\times$height for a rectangle. (This would be called Jordan measure though Jordan measure can be more complicated).

*Take all shapes that can be approximated from the inside by rectangles (e.g. pick a triangle and draw the largest rectangle you can completely inside it.  Then in the spaces left, draw the largest rectangles you can, and repeat until there is "no space left" -- this is a limiting process so you can't physically do it).  This gives us an inner measure (because it's done by drawing shapes inside).  If we do it with rectangles outside the shape then we get an outer measure.  If the inner and outer measures give the same answer, we have Lebesgue measure.
So this sounds easy, where's the catch?  That would lie in: 


*

*there is no ideal measure -- for whatever you're doing one measure might be better than another (compare counting measure and Lebesgue measure above: one is good for finite sets, the other for infinite sets).

*alongside there being no ideal measure, there are sets that cannot be measured (the Vitali set is a famous example of such a set).  So any function mapping the Vitali set into a measurable space cannot be measurable, because the pre-image is the Vitali set, which is not measurable.
So to your final question: whether a function is measurable or not depends entirely on the spaces you define it on and what measure-structure they have.  For most things you'll encounter outside of measure theory your functions will be measurable.
