An evil pony by the name of Zathir stabs him in/across the eye in an attempt to murder him in revenge for Spike’s interference that foiled his plan to take over Saddle Arabia and likely all of Equestria as well.

Luckily, the wound didn’t turn out fatal but it took the professional nursing skills of the Sultana of Saddle Arabia and a lucky break that Fluttershy still had a bat tooth with venom (Which in the context of the story that’s foreshadowed in Act 2, is said to have healing properties on living creatures) in it. The only side effect is it turns his eye purple. But otherwise he can still perfectly see with it. As they mention, they’d probably prefer to have two working eyes even if one is discolored then only one working eye. Which without the medicinal venom, Spike would of certainly lost that eye completely.