How did gay go from a positive word to a negative one? Because along the way it was used to refer to homosexuals, and lots of people hated (and still hate) homosexuals and want to distance themselves from that, and so everything else people hate becomes gay. Gay doesn't go from positive to negative without the hatred for homosexuals. Same goes for a word that means a cig or a bundle of sticks to become an insult.
Do words randomly change meaning over time? Sure. Are a disproportionately large number of them that have referred to homosexuals now all being used as insults? Yes, because of homophobia, and the continued use of these words as synonyms for bad is disparaging.