Why did we divide the region R into three regions? 
Here I cannot understand why we divided the region R into three while computing the expected value of |x-y|
 A: When $1<x<2$, $y$ is necessarily less than $x$. That's one region. 
when $0<x<1$, there are two sub-regions: $y<x$ (that's the second integral) and $y>x$ (that's the third). 
A: The entire region of integration includes some points where $x - y$ is positive and some where $x - y$ is negative.
This makes it very awkward to integrate in just one integral; do you see why?
So we are going to have at least two regions of integration.
One region is the triangle with vertices $(0,0),$ $(0,1),$ and $(1,1),$
and the other is the trapezoid with vertices 
$(0,0),$ $(1,1),$  $(2,1),$ and  $(2,0).$
If you decide the outer integral should be the integral over $dx,$
and the inner integral will integrate over $dy,$ then it is hard to integrate over the trapezoid using just one region: for $0 < x < 1,$ the upper bound on $y$ is given by $y = x,$ but for $1 < x < 2$ it is given by $y = 1.$
But actually it is not necessary to use three regions (one for the triangle and two for the trapezoid); the writer of this solution merely found it convenient.
It turns out that two regions actually are sufficient.
You can integrate over the trapezoid this way:
$$
\frac35 \int_0^1 dy \int_y^2 dx \, (x - y)x(y+y^2).
$$
You can substitute this integral into the solution instead of the sum of integrals
$$\frac35 \int_1^2 dx \int_0^1 dy \, (x - y)x(y+y^2)+
\frac35 \int_0^1 dx \int_0^x dy \, (x - y)x(y+y^2).$$
