That's an essential question! In fact, the DSA would be totally invalid if $r = g^k$ was not imposed.
Suppose that Eve is allowed to pick two arbitrary numbers:
- $r_1$ for calculating the signature $s := (m + xr_1)k^{-1} ~ (mod~q)$ (where $m$ denotes the Hash of the message, which would be $H(m)$ when written in full.), and --
- $r_2 := g^k ~(mod ~ p) $ from the random number $k$, used only in the last comparing step of verification.
Thus the signature should contain all the three numbers: $<s, r_1, r_2>$, so that $r_2 = g^{m\omega}y^{r_1 \omega}~(mod~p)$ provides a plausible verification check for $m$ (where $\omega := s^{-1} ~(mod~q)$).
However, the freedom of choosing $r_1, r_2$ without imposing $r_1 = r_2$ makes the algorithm vulnerable against attacks.
Without the private key $x$, and even without bothering to choose $k$, a dishonest signer Eve can freely pick up ANY two random lucky numbers $s$ and $r_1$ as the claimed "signagure", as long as $r_2$ is deliberately chosen as:
- $r_2 := g^{m \omega} y^{r_1 \omega}$ $mod~p$.
which makes the signature $<s, r_1, r_2>$ always valid for $m$ unless $k$ or $x$ is made public.
The essential principle is that only the honest signer using the true values of $x$ and $k$ can get the above result with $r_1 = r_2$ satisfied.
(The last step $mod ~ q$ in verification is omitted since its just a unification step to make the compared values below $q$. Also the signature $<s, r>$ is equivalent to $<\omega, r>$ where $\omega := s^{-1} ~(mod ~ q)$ since the calculation of the reverse number is also trifle)