They are of particular prominence in the Forgotten Realms setting, where they used to rule the world, or at least are one of the direct successors to a pre-humanoid empire, and in Eberron, where they have coatl-based good-aligned counterparts who serve the Silver Flame . In generic D&D, they are usually portrayed as descendants of mad serpent-worshipping witch-cults that fused and interbred with snakes in order to "evolve" into superior beings. Perhaps as a result of this, yuan-ti are commonly portrayed as having not only unusual, snake-based magical spells, but a natural talent for psionics.
Zehir is their racial deity. Unusually this wasn't revealed till late 3.5 and he's not actually in any books from that era. His debut was as the ultimate antagonist of Storm of Zehir, the second expansion pack of Neverwinter Nights 2, which means there is plenty of Yuan-ti stuff in the campaign. Before this retcon, they originally worshiped Merrshaulk, but later switched to Sseth, who was later replaced without the Yuan-ti realizing it by Set, although currently it seems that Set and Zehir were the same god all along.
According to the book Serpent Kingdoms, the Yuan-ti were originally created as a servant race by an older race of snake people called the Sarrukh, who also created several other Scalykind races, but the Yuan-ti rebelled and nearly drove them to extinction. This was only canon to Forgotten Realms and has been ignored in later editions. Some heretical Yuan-ti claim that their creator actually was Sertrous.
There are six tiers of Yuan-ti, ranked based on their proportion of snake features (with the exception of broodguards).
Purebloods are mostly human, with minimalistic serpentine traits that are easy to conceal (a forked tongue, snake-like eyes, a body covered in very pliant scales colored like human skin, a vestigial tail, snake fang-like canines, small patches of visible scales etc). Because yuan-ti worship snakes, these guys are actually on the bottom of the pecking order in their own society, although they are useful for infiltrating humanoid societies. In 5th edition, the fact they spend a lot of time around humans, where they have much more freedom and respect than they do at home, was used as an excuse to give them PC stats.
Malisons are more drastically serpentine, which boosts them above Purebloods in the pecking order. This subspecies exemplifies the mutability of the yuan-ti; in 5th edition, at least, there are five recognized "forms" of malison, and many variations within those form archetypes. One type looks a lot like the "common" vision of a lamia, having a human upper torso and a giant snake's body in lieu of legs. Two other types look like humans with either serpent heads or serpent tails in place of arms (the mouth-handed ones are higher up the pecking order). One type looks like a human with a snake's head. And the last known type, lowliest of all, simply looks like a human with scaly skin.
Abominations are the most iconic and, in their own culture, favored of their breed. These look like either giant snakes with humanoid arms or lamias with scaly skin and a snake-like head. These guys are the undisputed top of the totem pole... except for one last class;
Anathemas, are essentially a hydra version of abominations; bigger, claw-fingered, and with six snake's heads in place of one. Anathemae are worshipped as demigods. Depending on the setting, they are either the rulers of the entire race, or they may just be the leaders of their own small cults because their presence is destabilizing to Yuan-ti society so they are cast out of Yuan-ti cities. The 4th edition version of the anathema instead looks like a large snake's head attached to a body made out of numerous smaller snakes. They were once the rulers of the Yuan-ti race before all of them went insane and were locked up.
There also are two other types of Yuan-ti called brood guards and tainted ones that are below even Pureboods. Both of these are created by transforming humans using a potion made of Yuan-ti venom. Brood guards are ugly and unintelligent reptilian creatures that the Yuan-ti use for guarding their eggs. Tainted ones are similar to purebloods but their snake features are even more subtle, so they are used as infiltrators.