Think of the Pumping Lemma as a game in which you're trying to prove that a language isn't regular, while someone else is "defending" the regularity of this language. Here is how to play the game:
- The defender specifies the pumping length $n$. Think of it as the number of states in the automata that recognizes the language.
- You give the defender a word $w$ from the language that satisfies the condition: $|w| \ge n$.
- The defender divides this word into $xyz$, where $|xy| \le n$ and $|y| > 0$. This division must also satisfy the condition that $xy^{k}z$ belongs to the language $\forall k \ge 0$.
If you give the defender a word that is impossible to divide under the conditions in step 3, you win and the language isn't regular.
Given the above, let's have a look at your answer. You gave the word $0^{n}1^{n-1}$. I'll play the role of the defender and divide it as: $0^{n-1}01^{n-1}$ where $x = 0^{n-1}$, $y = 0$ and $z = 1^{n-1}$. This division satisfies all of the conditions above:
- $|xy| = |0^n| \le n$
- $|y| = |0| = 1 \ge 0$
- $xy^{k}z = 0^{n-1}0^{k}1^{n-1} = 0^{n+k-1}1^{n-1} \in L$
The last condition is justified because:
$$
k \ge 0 \Rightarrow n+k-1 \ge n-1
$$
Thus, your word doesn't make it impossible for me to divide the word in a way that satisfies the Pumping Lemma's conditions.
Now, what if we consider $0^{n}1^{n}$ instead? No matter how I divide it, $x$ and $y$ will always fall within the $0^n$ part since $|xy| \le n$. Therefore, $y$ will consist of one or more $0$s. For $k = 0$, one or more $0$s will be removed and the number of $0$s in the string will be less than the number of $1$s, and the word will no longer be in the language. Hence, the language isn't regular.