Just because we can (and as an exercise): ;)
The graphs of $y=g(x)$ and $y=x$:
\begin{tikzpicture}
%preamble \usepackage{pgfplots}
\begin{axis}[xmin=-3, xmax=3, ymin=-3, ymax=3]
\addplot[blue, thick, samples=101] (x, {x^3-2*x+1}) node at (-1.8,2) {$y=g(x)$};
\addplot[red, thick] (x, x) node at (-0.5,-1.2) {$y=x$};
\end{axis}
\end{tikzpicture}
The graph of $y=f(x)$ as defined by MarkFL.
\begin{tikzpicture}
%preamble \usepackage{pgfplots}
\begin{axis}[xmin=-3, xmax=3, ymin=-3, ymax=3]
\addplot[blue, thick, samples=101] (x, {x^3-3*x+1}) node at (-2.2,2) {$y=f(x)$};
\addplot[red, thick] (x, 0) node at (-0.7,-0.3) {$y=0$};
\end{axis}
\end{tikzpicture}
And sign schemas of $f$ and $f'$, showing where the graph slopes up and down, and where we will find zeroes:
\begin{tikzpicture}
\draw (-3,2) node
{$f$} -- (3,2);
\draw (-2,1.9) node[below] {-2} -- (-2,2.1) node[above] {-1};
\draw (-1,1.9) node[below] {-1} -- (-1,2.1) node[above] {+3};
\draw ( 0,1.9) node[below] {0} -- ( 0,2.1) node[above] {+1};
\draw ( 1,1.9) node[below] {+1} -- ( 1,2.1) node[above] {-1};
\draw ( 2,1.9) node[below] {+2} -- ( 2,2.1) node[above] {+3};
\draw (-3,0) node
{$f'$} -- (3,0);
\node at (-2, 0.2) {$+$};
\draw (-1,-0.1) node[below] {-1} -- (-1,0.1) node[above] {0};
\node at (0, 0.2) {$-$};
\draw ( 1,-0.1) node[below] {+1} -- ( 1,0.1) node[above] {0};
\node at (2, 0.2) {$+$};
\end{tikzpicture}
We can see that we have 3 zeroes in respectively the intervals $(-2,-1), (0,1), (1,2)$.