It's a joke that originated online rather than in D&D canon.
During the era when TSR published AD&D (1977 to 1997), there was an internal policy to avoid potentially offensive content, including sexual content or works depicting explicitly Judeo-Christian religious elements. After Gary Gygax left the company in the mid-1980s, they even banned the names "demon" and "devil" for fear of offending religious parents. TSR's James M. Ward even had an official policy for this, called the Angry Mothers rule.
AD&D's bards weren't entirely sexless. It would have been generally understood that bards, as performers, would need to be good-looking and charming, more so than any other character class. The Complete Bard's Handbook (1992) even had a kit called the Gallant, a romantic warrior whose hobbies including romancing the opposite sex.
In D&D 3rd edition (2000), the d20 System allowed characters of any class to roll Charisma checks, including checks to influence NPCs. The bard in particular became the "party face", i.e. the guy who initiates all conversations with NPCs because they have the highest number. Sorcerers also had high Charisma, but didn't have the Diplomacy skill, and paladins had to split their stats among other ability scores so they didn't always have the best Charisma. Bards also had more spells and abilities for charm purposes. The bard thus became the iconic character for influencing people, including those of the opposite sex.
It's not really until everyone got online that the "horny bard" trope arose. TV Tropes' page on the matter mainly cites post-2000 sources and web content, which seems to support this.
The origin of the "horny bard" appears to be the D&D parody movie The Gamers: Dorkness Rising (2008), which has this exchange:
Leo: I seduce the priestess!
Lodge: She's taken a vow of celibacy!
Leo: Dude, 20 ranks in seduction!
Flynn the Fine: [to priestess] Hey, baby. Wanna tune my mandolin?
[rolls and the priestess and Flynn leave the room]
Daphne: [to Hierophant] Please understand the horny bard does not represent us.
This in turn probably reflects the Dead Alewives sketch (1996 or so) which has this exchange involving a player character (not a bard) in a tavern:
Player: Ogres? Man, I got an ogre slaying knife, it's got a +9 against ogres!
DM: You're not there, you're getting drunk!
Player: Alright, but if there's any girls there, I wanna do them!
Dorkness Rising certainly helped the popularize the term, though it isn't the earliest known use of the phrase "horny bard". For example, in this thread, dated December 2005:
In one Diskworld-esque game that never got entierly off the ground, I had a horny bard named Randy.
The "horny bard" trope has seen a surge of popularity post-2020. The earliest YouTube results for the term are May 2021, except for one obscure Witcher 3 video dated June 2016. A video game soundtrack by a band named Horny Bard appears on Steam dated June 2021. I suspect that the trope has been popularized recently by appearances at Reddit's /r/dndmemes. It may also have a connection to a related trope where dragons are promiscuous, which comes from D&D 3.5's popular half-dragon template and the notion that sorcerers are often descended from dragons.