It would have been a great story, but it is a lie. Mrabet did compete against the Israeli and was in the pool at time - but he was disqualified.
From Tunisia Live:
Tunisia’s quest for Olympic glory is off to a rocky start as Taki Mrabet has been disqualified in the first heat of the 400m Individual Medley.But perhaps he purposefully drew a foul so as not to enter the same disgusting waters as the Israeli?
Violations punishable by disqualification include not observing the required strokes during the medley (butterfly, backstroke, breaststroke, and freestyle) and exceeding the underwater distance limit in the freestyle section, among other violations.
According to the news agency TAP, Mrabet was disqualified by a judge for a technical foul.
Well, no. Here is the video of the heat, showing all eight swimmers in the pool, that I grabbed from Israel's "One" website (UPDATE - video taken down for copyright violation but you can see it on the Israeli site..)
Israeli swimmer Gal Nevo is in lane 1, Mrabet is in lane 8, as the NBC Olympics site shows:
So in reality, the Tunisian was disqualified for a technical foul, but he did try to compete against Israel. And now fans are trying to cover up for his ignominious outing by pretending that he disqualified himself on principle.