The story
From fag (“homosexual man, annoying person, etc.”). Cf. -man. Popularized on the 4chan online community (see also Christopher "Moot" Poole's tripcode of #faggot). First attested in c. early 2000s. For similar semantic drift in slang from derogatory to neutral, ironic or affectionate, compare some senses of bugger, cunt, etc.
Etymology from Wiktionary, CC BY-SA 4.0.