Under what conditions is $\vert x-y \vert = \vert x \vert -\vert y \vert$? This is a fairly basic question, however, I don't know what I am missing here. Solving the equation $\vert x- y\vert = \vert x \vert -\vert y \vert$ yields:
\begin{align}
\vert x- y\vert &= \vert x \vert -\vert y \vert \\
(x-y)^2&=x^2+y^2-2\vert xy\vert \\
xy & = \vert xy \vert
\end{align}
Which is obviously true if $xy\geq 0$. However, if I set $x=0$, this equality does not hold. For instance $x=0$ and $y=5$, then:
$$
\vert0-5\vert=\vert0\vert-\vert5\vert \\
5 = -5
$$
On the other hand, if $y=0$, it works out fine. So, I would conclude that we need $xy\geq 0$ and $x \neq 0$ for this equation to hold. I wonder whether there is an "analytical way" to see this rather than plugging in numbers.

You have that
$$
|x-y| = |x| - |y| \qquad\implies\qquad
(x-y)^2 = x^2 + y^2 - 2|xy|
$$
which is an implication but not an equivalence. The problem is that squaring adds solutions, for example $1\neq-1$ but $1^2=(-1)^2$.
If you'd take the square root of the right equation, you'd get $$|x-y| = \big|\,|x|-|y|\,\big|$$
The left side, however, must have $|x|\geqslant|y|$. Thus:
$$
|x- y| = |x| - |y| \qquad\Longleftrightarrow\qquad
(x-y)^2 = x^2 + y^2 - 2|xy| \ \text{ and }\ |x|\geqslant|y|
$$

One way to solve the equation is the rather tedious split into cases:
$$|x-y| = |x| - |y| \quad\Longleftrightarrow\quad
\begin{cases}
x-y = x-y; &x\geqslant y, x\geqslant 0, y\geqslant 0 \\
x-y = x+y; &x\geqslant y, x\geqslant 0, y < 0 \\ 
x-y = -x-y; &x\geqslant y, x < 0, y\geqslant 0 \\
x-y = -x+y; &x\geqslant y, x < 0, y < 0 \\ 
y-x = x-y; &x < y, x\geqslant 0, y\geqslant 0 \\
y-x = x+y; &x < y, x\geqslant 0, y < 0 \\ 
y-x = -x-y; &x < y, x < 0, y\geqslant 0 \\
y-x = -x+y; &x < y, x < 0, y < 0 \\ 
\end{cases}$$
Some cases vanish because they are always false, others reduce due to $x=0$ or $x=y$:
$$|x-y| = |x| - |y| \quad\Longleftrightarrow\quad
\begin{cases}
\text{true}; &x\geqslant y\geqslant 0 \\
x = y; &x\geqslant y, x < 0, y < 0 \\ 
y = 0; &x < y, x < 0, y\geqslant 0 \\
\text{true}; &x < y < 0 \\ 
\end{cases}$$
That is:
$$|x-y| = |x| - |y| \quad\Longleftrightarrow\quad
\begin{cases}
x\geqslant y\geqslant 0 \\
x = y < 0 \\ 
x < y \leqslant 0  \\
\end{cases}$$
This 3 cases can finally be rewritten as 2 cases:
$$|x-y| = |x| - |y| \quad\Longleftrightarrow\quad
\begin{cases}
x \geqslant y\geqslant 0 \\
x \leqslant y \leqslant 0 \\ 
\end{cases}$$
