It is case $\rm\:(k,n) = (5,p\!-\!1) = 1\:$ of the Easy k'th Power Criterion that I mentioned recently.
Suppose $\rm\, g^n = 1.\,$ Then exponents on $\rm\,g\,$ can be interpreted $\rm\ mod\ n\!:\ i \equiv m\:$ $\Rightarrow$ $\rm\,g^i = g^{m}.\ $ So it is
clear that $\rm\,g^i\,$ is a $\rm\,k$'th power if $\rm\ mod\ n\!:\, k\mid i,\ $ i.e. $\rm\ i\equiv jk,\,$ so $\rm\,g^i = g^{jk} = (g^j)^k.\,$ By $\rm\color{#C00}{Bezout}$
$$\rm k\,|\, i\ \ (mod\ n)\!\iff\! \exists\,j\!:\ jk\equiv i\:\ (mod\ n)\!\iff\! \exists\, j,m\!:\ jk \!+\! mn = i\color{#C00}{\!\iff\!} (k,n)\,|\, i$$
Hence we have conceptually derived a proof of the following
Theorem $\rm\ \ \ g^n = 1,\,\ (k,n)\mid i\:\Rightarrow\: g^i\,$ is a $\rm\,k$'th power $\ \ $ [Easy $\rm\,k$'th Power Criterion]
Proof $\rm\ \ By\ Bezout,\,\ (k,n)\mid i\:\Rightarrow\:k\mid i\ \ (mod\ n)\: \Rightarrow\:i\equiv jk\ \ (mod\ n)\:\Rightarrow\: g^i = g^{jk} = (g^j)^k$
Note $\,\ $ That $\rm\ \ k\,|\, i\:\ (mod\ n)\!\iff\! (k,n)\,|\: i\ \, $ frequently proves conceptually handy, $ $ e.g. $ $ see here. $\ $ The reason behind this will become clearer when one studies cyclic groups and (principal) ideals.