For $x<0$ the distance to $I$ is the same as the distance to $0$, so $f(x)=-x$. For $x\in I$ the distance f(x)=0 and for $x>1$ we take the distance to $1$: $f(x)=x-1$. This results in the following graph around $I$.

For a function $f$ to be differentiable in $x_0$ the "slope" has to be continuous, so it has to be the same approaching from the left as from the right. Formally a function $f$ is said to be differentiable in point $x_0$ if
$$
\lim_{h\to 0}\frac{f(x_0+h)-f(x_0)}{h}
$$
exists. From the graph we can see that there might be a problem in $x_0=0$ and $x_0=1$. Take a look at the limit in $x_0=0$:
$$
\lim_{h\to 0}\frac{f(0+h)-f(0)}{h}=\lim_{h\to 0}\frac{f(h)}{h}.
$$
Leting $h$ approach $0$ from positive values we find $f(h)=0$ so the limit evaluates to $0$. Letting $h$ approach $0$ from negative values we find $f(h)=-h$ so the limit evaluates to $\frac{-h}{h}=-1$. Because the limit from the right isn't the same as the limit from the left we say that the limit does not exist and as a result $f$ is not differentiable in $x_0=0$.
The same argument applies to $x_0=1$.