To find the maximum value of the function, we first take the derivative of \( f(x) \):
\[
f'(x) = 4x^3 - 16x
\]
Now, set \( f'(x) = 0 \) to find the critical points:
\[
4x^3 - 16x = 0 \implies 4x(x^2 - 4) = 0 \implies x = 0, \, \pm 2
\]
Now, evaluate \( f(x) \) at \( x = -2, 0, 2 \):
\[
f(-2) = (-2)^4 - 8(-2)^2 + 2 = 16 - 32 + 2 = -14
\]
\[
f(0) = 0^4 - 8(0)^2 + 2 = 2
\]
\[
f(2) = (2)^4 - 8(2)^2 + 2 = 16 - 32 + 2 = -14
\]
The maximum value occurs at \( x = 0 \), where \( f(0) = 2 \).
Thus, the maximum value of the function is \( \boxed{2} \).