First, you were not there & do not know the whole story. Second, your opinion whether "he didn't actually do anything" is irrelevant. A country actually can deport any foreigner at any time for any reason, or simply revoke their visa, let the visa expire, etc. Some countries are more "by the book" than others, too.
Anyone who is deported is, for whatever reason, undesirable, therefore deportees are permanently barred from reentry.
If your friend is gay, or could be suspected of it, he never should have gone to any muslim country to begin with. It's illegal there, and persecution as well as prosecutions are vigorously pursued. It's not just a matter of "discrimination" or "intolerance" but of extreme hostility.