Question: Is there a differentiable function $f : [0,2] \rightarrow [0,1]$ such that $f(x) = 0$ iff $x=0$ and $f(x) = 1$ iff $x \in [1,2]$? What about $n$ times differentiable for any $n$, or infinitely differentiable? Thank you!

Answer: 
First, let

$$f(x)=\begin{cases}e^{\frac{-1}{x}}&x>0\\0&x\le0\end{cases}$$

It can be shown that $f$ is smooth. Then one such desired function is

$$g(x)=\frac{f(x)}{f(x)+f(1-x)}$$

Since $f$ is smooth, and $f(x)+f(1-x)$ is never $0$, $g$ is also smooth. $g$ takes values $0$ for $x<0$, and values $1$ for $x>1$. It's called a smooth transition function.
*This just addresses the "does there exist such a function" with only one differentiation.*

We want $f'(x) = 0$ for $x \in [1, 2]$ so that the function is constantly $1$. We could define such a function piecewise:

$$f(x) = \begin{cases}
\sin^2\frac{\pi x}{2} & 0\le x \lt 1 \\
1 & 1 \le x \le 2
\end{cases}$$