Taylor's theorem states that f(x) = f(a) + f'(a)(x-a) + \frac{f''(a)}{2!}(x-a)^2 + \cdots + \frac{f^{(k)}(a)}{k!}(x-a)^k + \frac{f^{(k+1)}(\xi_L)}{(k+1)!} (x-a)^{k+1}, where $\xi_L$ is between $a$ and $x$.
This will help us finding the function if we take $a=0$. First note that by Lagrange's theorem for $x >0$ we have f(x)-f(0)=f'(c)x, \ c \in [0,x]. Therefore, there exists $c_k \in (0,1/k)$ with f'(c_k)=0. We can pick a decreasing subsequence of this sequence, and denote it for simplicity with (the same) $(c_k)$. Since f'(c_k)=0 and $c_k \to 0$ it follows that f'(0)=0.
Doing the same think with $(c_k)$ instead of $1/k$ we get that f''(0)=0 and inductively $f^{(n)}=0$, for all positive integers $n$.
Pick $x \in [-1,1]$. By Taylor's formula around zero we get that $f(x)=\frac{f^{(k+1)}(\xi_L)}{(k+1)!} x^{k+1}$ and using the bound on the derivatives we get $ |f(x)| \leq \frac{M}{(k+1)!}|x|^{k+1}$ for all positive integers $k$.
Taking $ k \to \infty$ we get that $f(x)=0$. Since $x$ was arbitrary, the problem is solved.