So a primitive root/element $g$$\pmod{n}$ is an element in $\mathbb Z^*_{n}$ such that when $g$ is raised to each element in $\mathbb Z^*_{n}$ it generates the whole set of $\mathbb Z^*_{n}$
But the way to find a primitive root seems totally unrelated to me. You try $2$, then $3$, etc until you get a number that has no $\equiv 1\pmod{n}$
Why is an element $g$ not primitive$\pmod{n}$ if $g^\frac{n-1}{f} \equiv 1\pmod{n}$ for some prime factor $f$ of $n-1$? I don't see the connection