Hint: some arguments might be simpler if you recall the trigonometric formula $2\sin(x)\cos(x) = \sin(2x)$. Remember also that $\cos$ and $\sin$ are $2\pi$-periodic functions.
I am a bit lost with this question. I wanted to apply the contraction mapping theorem but it involves a closed set which $\Bbb R$ isn't. So I started off with let $a \in \Bbb R$ and $a > 0$, then the set $[-a,a] = I$ is a subset of $\Bbb R$ which $f(x)$ is defined on.
Then assume for some $x_1 \in I$, $f(x_1) = x_1$ and $x_2$. I was then going to apply the mean value theorem where $f'(c) = \dfrac{f(x_1) -f(x_2)} {x_1 - x_2}$ which would mean $f'(c) = 0$, however $f '(x)$ is $2e^{-\cos(x)^2}\cos(x)\sin(x)$ which will not equal to $0$?
I am not sure if I am heading in the right direction because so far it doesn't look right
Note that $\Bbb R$ is a complete metric space, which is all we need to appeal to the contraction mapping theorem.
Assume $x_1, x_2 \in \Bbb R$ with $x_1 < x_2$. Then, by MVT, we have that $$f'(c) = \dfrac{f(x_2) - f(x_1)}{x_2 - x_1} \qquad (*)$$ for some $c \in (x_1, x_2)$.
Thus, to show that $f$ is a contraction, it would suffice to find a nice bound on $f'(c)$. We turn our attention to this.
Note that $f'(x) = e^{-\cos^2x}\sin2x.$
We now show that there exists $k \in (0, 1)$ such that $|f'(x)| < k$ for all $x\in \Bbb R$. Note that $f'$ is periodic with period $\pi$ and thus, it suffices to consider $f'$ on $[0, \pi]$.
However, note that $I = [0, \pi]$ is compact and so, by the extreme value theorem (EVT), $|f'|$ attains its maximum (supremum) on it.
Let $k = \displaystyle\sup_{x\in I}|f'(x)|.$ By EVT, $k = |f'(x_0)|$ for some $x_0 \in I$.
We now wish to show that $k < 1$. (Emphasis on the strict inequality. It is clear that $k \le 1$.)
Note that $e^{-\cos^2x} \le 1$ and $|\sin 2x| \le 1$ for all $x \in I$. Thus, if $k = 1$, then we must have both $$e^{-\cos^2x_0} = 1 \text{ and } |\sin 2x_0| = 1.$$
However, it can be seen that the former is possible iff $x_0 = \pi/2$ corresponding to which we get that $\sin 2x_0 = 0$, a contradiction. Thus, we see that $k = 1$ is not possible.
With the above result, we can rearrange $(*)$ to get \begin{align} \left|\dfrac{f(x_2) - f(x_1)}{x_2 - x_1}\right| &= |f'(c)|\\ &< k\\ \implies |f(x_2) - f(x_1)| &< k|x_2 - x_1|, \end{align} for some $k \in (0, 1)$ and all $x_1, x_2 \in \Bbb R$.
You can now appeal to the contraction mapping theorem and conclude the result.