Let's talk about the origins of D&D's elves: they're literally the children of a god, rather than the creation of a god. Kind of. Actually, they're Corellon Larethian's blood--literally.
From "his" description, Corellon sounds like a genderfluid Freddie Mercury, prancing throughout the multiverse with swagger, changing gender and shape (seriously, sometimes he's, like, a flock of birds or a swarm of birds or whatever).
Gruumsh, god of the orcs, took exception to Corellon's flamboyant fluidity, which leads to their big fight in which Gruumsh loses an eye. If you look at this slightly sideways, it makes Gruumsh into the avatar of homophobia or transphobia or some other weird prejudice.
Seriously, check me on this. This is what the text actually says: "Corellon's flamboyant, mercurial personality showed through no matter which form the entity took. Corellon loved wholeheartedly, broke oaths without reservation, and took pleasure from every encounter with the other divine beings of the multiverse. Most of the gods accepted Corellon's mutability and passionate behavior, but these traits infuriated Gruumsh, the greatest of the orc gods."
Interestingly, Corellon's rift with Lolth (which leads to the rift between Regular Elves and Drow) is also thrown into strange waters: Lolth's "betrayal" was to urge the elves to adopt stable, mortal, gendered forms instead of following in Corellon's footsteps as ever-shifting fey creatures. This makes the problem with Lolth that she is a gender essentialist. It's noted that Lolth insisted on being a "she."
Modern concerns aside, there is also an element of Edenic myth to the story. Once the elves chose physical forms over changeable fey-ness, Corellon locked them out of Elf Heaven. When elves die, their souls can go to Elf Heaven maybe for a little bit, but they're doomed to reincarnation. At least this explains why there are so few elves despite their long lives: there are only a finite number of elf souls to go around.
But, I also want to point out that Corellon doesn't seem nearly as chaotic good as he's supposed to be. The elves' only hope to get back to Elf Heaven is Corellon changing his mind--which you think a chaotic god might do--but he seems pretty steadfast in punishing the elves' transgression.
Second, he doesn't seem particularly good--he doesn't seem to value forgiveness or really give a fuck about his "children." Particularly when you realize that the "trance" elves go into instead of sleeping is a time when they have to relive all their past lives with the knowledge that they're in a perpetual, unwanted cycle of death and rebirth, it seems a little cruel.
So, if you ever wondered why elves were jerks, it turns out they came by it honestly from their parent.