Someone wanted to destroy the GTS for the lulz (they felt putting a load of crudely nicknamed Pokemon would be the best way) so they purchased a cyber gadget (this should give you an idea of how long ago this was) and edited their savefile (the fact they had to do that to edit their save shows how long these have been lingering for). As for the how? The profanity check on nicknames wasn't done upon uploading to GTS. No idea if it is still like that.
My fiancée and I were discussing the aspect of the profane nicknames and we both basically agreed that, since there will always be people trying to get around the checks/censors, Game Freak might as well now concede the whole "can't rename other people's Pokémon" angle.
It's 2015 and closing in on two decades for this series--this crap isn't going to go away.