Example 3 Given $|z|=1$, find the maximum and minimum values of $\left|z^{3}-3 z-2\right|$.
Notice that $z^{3}-3 z-2=(z+1)^{2}(z-2)$, let $z=x+y i(x, y \in \mathbf{R})$, then $x^{2}+y^{2}=1$.
$$
\begin{aligned}
\left|z^{3}-3 z-2\right| & =\left[(x+1)^{2}+y^{2}\right] \sqrt{(x-2)^{2}+y^{2}} \\
& =(2 x+2) \sqrt{5-4 x} \\
& =\sqrt{(2 x+2)(2 x+2)(5-4 x)} \\
& \leqslant\left(\frac{2 x+2+2 x+2+5-4 x}{3}\right)^{\frac{3}{2}}=3 \sqrt{3},
\end{aligned}
$$

Equality holds if and only if $x=\frac{1}{2}$. Therefore, the maximum value sought is $3 \sqrt{3}$.
It is easy to see that when $z=-1$, $\left|z^{3}-3 z-2\right|$ has a minimum value of 0.