This is mainly by design. The explanation you give yourself in the comment is correct.
The (TeX) command \cases
is unusual, in that while it is mainly "math" the part after the ampersand (&) is "text" as you said.
Indeed, this initially was not handled properly in MathJax but by now is fixed see https://github.com/mathjax/MathJax/issues/32
Yet, in fact the fix is what causes the problem for you.
To see this note how the letter I is rendered differently depending on its position before or after the amersand.
$$
\cases{
I & I \cr
I & I }
$$
$$\cases{
I & I \cr
I & I }$$
That adding the \text
puts the remainder after the text in math-mode and fixes the problem is quite odd, I think. This may qualify as bug, not sure. It ought to be due to the fact that you somehow manage to start text-mode while in text-mode, which should do nothing and not even be possible (note it only works when you start it right after the ampersand). When you leave text-mode you are "back" in (default) math-mode.
$$
\cases{
I & \text{I}I \cr
I & I }
$$
$$
\cases{
I & \text{I}I \cr
I & I }
$$
$$
\cases{
I & I\text{I}I \cr
I & I }
$$
$$
\cases{
I & I\text{I}I \cr
I & I }
$$
All that said, I would just not use \cases
at all.
Rather use \begin{cases} ... \end{cases}
which does not have this unusual feature, and generally is more in line with other constructs. (I'd use \\
instead of \cr
but both seem to work.)
$$
\begin{cases} 0,&x=y\cr
1,&x\neq y \end{cases}
$$
$$
\begin{cases}
0,&x=y\cr
1,&x\neq y
\end{cases}
$$
If you really want to use \cases
(and not switch to \begin{cases}
) in the way you intended to, you can start the math-mode after the ampersand explicitly adding dollars, like:
$$d_{1}\left(x,y\right)=\cases{
0,& $x=y$ \cr
1,& $x \neq y$ }$$
$$d_{1}\left(x,y\right)=\cases{
0,& $x=y$ \cr
1,& $x \neq y$ }$$
\cases
is text, not a formula. But\text
(drhab told me about it) makes it a formula? Hmm... How about$$d_{1}\left(x,y\right)=\cases{ 0,&$x=y$\cr 1,&$x\neq y$}$$
? $$d_{1}\left(x,y\right)=\cases{ 0,&$x=y$\cr 1,&$x\neq y$}$$Yes, it works. $\endgroup$