The Clinton Administration refused to defend, and eventually secured repeal, of legislation mandating the discharge of HIV positive personnel.
A somewhat informal and erratically enforced ban on homosexuals in the military before and during WWII was formalized after WWII as a result of bad experiences DURING WWII-obnoxious behavior, sexual harassment, in the Navy especially of predatory officers and NCOs, and I suspect high rates of venereal infection. In the words of WWI veteran President Harry Truman "Homosexuality and military service are incompatible."