Let $g$ be a generator of $G$. Let $g^m$ be another generator, with $2 \le m \le n-1$. This means that $(g^m)^k \ne e$ for all $1 \le k \le n-1$, i.e. $n \nmid mk$ for all $1 \le k \le n-1$.
If $\gcd(n,m) = d > 1$ then, letting $m = da$ and $n = db$, the above condition becomes $b \nmid ak$ for all $1 \le k \le n-1$. Since $d>1$, it follows that $b<n$, so if you choose $k=b$ you get $b \mid ab$, which is contradicts the assumption that $n \nmid mk$ for all $1 \le k \le n-1$. It follows that, necessarily, $\gcd(n,m) = 1$.
Let us show that the condition $\gcd(m,n) = 1$ is also sufficient for $g^m$ to be a generator. Assume there exist $2 \le k \le n-1$ with $(g^m)^k = e$. Since $\gcd(m,n) = 1$, by Bézout's theorem there exist $s,t \in \Bbb Z$ such that $sm + tn = 1$, which implies $smk + tnk = k$, whence it follows that
$$e = e^s = (g^{mk})^s = g^{mks} = g^{k - tnk} = g^k (g^n)^{-tk} = g^k ,$$
so $g^k = e$, which contradicts the fact that $g$ is a generator.
We have discovered that in order for $g^m$ to be a generator, it is necessary and sufficient that $\gcd(m,n)=1$, for $2 \le m \le n-1$. How many numbers coprime with $n$ do we have in $\{2, 3, \dots, n-1\}$? By definition, $\varphi(n)-1$, where $\varphi$ is Euler's totient function. We have a "$-1$" because we start counting from $m=2$; taking into consideration that $g$ is a generator, too, and it corresponds to $m=1$, we get a total of $\varphi(n)$ generators.