Can the Identity Map be a repeated composition one other function?
Solution 1:
Consider the class of Möbius transformations: $$f(x) = {ax+b\over cx+d}$$ for some constants $a,b,c,d$. If we represent Möbius transformation $f$ by its matrix of coefficients: $$\hat f = \pmatrix{ a&b \\ c&d }$$ then it turns out that to compose two Möbius transformations $f$ and $g$ we just multiply their corresponding matrices.
In particular, if $f$ is a Möbius transformation with matrix $\hat f$, then $f(f(f(x)))$ is also a Möbius transformation, with matrix ${\hat f}{}^3$.
So it suffices to find a $2\times 2$ matrix $M$ with $M^3 = I$. There are numerous examples, but one such is $$\def\ang{{\frac{2\pi}3}}\pmatrix{\cos\ang & \sin\ang \\ -\sin\ang & \cos\ang} = \pmatrix{-\frac12 & \frac{\sqrt3}2 \\ -\frac{\sqrt3}2 & -\frac12 }.$$ This is just the matrix for the linear transformation of the plane that rotates the plane by a one-third turn about the origin.
So the corresponding Möbius transformation with period 3 is $$f(x) = {x-\sqrt 3\over x\sqrt3 + 1}.$$
By replacing $2\pi\over 3$ with $2\pi\over n$, you can construct a function with any period you want.
Note that you are not restricted to $M$ with $M^3 = I$. Since $I$ and $kI$ are the same when considered as Möbius transformation, $M^3 = kI$ will work for any $k$.
Solution 2:
The function $$f(x) = {1\over 1-x}$$ has $f^3(x) = x$ for all $x$ where $f^3(x)$ is defined. (All reals except for 0 and 1.)
Other than the identity, there is no continuous function $\Bbb R\to \Bbb R$ having $f^3(x) = x$ for all $x$, by Sharkovskii's theorem.
Solution 3:
Consider the function $f:\mathbb R\to\mathbb R$ such that $f(i)=i+1$ for all $i\in\{1,\dots,p-1\}$, $f(p)=1$ and $f(x)=x$ for all $x\in\mathbb R\setminus\{1,\dots,p\}$.
Solution 4:
If you don’t impose any other conditions on $g$, it’s certainly possible. For $n\in\Bbb Z$ let $I_n=[n,n+1)$, and define
$$g:\Bbb R\to\Bbb R:x\mapsto\begin{cases}x+1,&\text{if }x\in I_n\text{ and }3\not\mid n\\ x-2,&\text{if }n\in I_n\text{ and }3\mid n\;. \end{cases}$$
This map translates $I_{3k+1}$ to $I_{3k+2}$, $I_{3k+2}$ to $I_{3k+3}$, and $I_{3k+3}$ back down to $I_{3k+1}$; it fixes no points of $\Bbb R$.
This generalizes: you can replace $3$ by any integer $m\ge 2$.