It is believed all snakes came from lizards. Monitors, of the old world, Africa, Asia, and Indo-Australia, (genus varanus), and tegus, the new world equivalent, (genus tupinambis), are the closest lizards currently still alive, to snakes. They have forked tongues that deliver molecules in the air to their jacobson's organ to "taste" the scent in the air, similar to snakes. And they move in a very similar "slithering" manner, albeit with legs. And all can swallow whole prey in a manner similar to a snake, though most will eat carrion as well as smaller prey such as insect and fish.
And the snake families pythoninae & boidae both have vestigial hind limbs, the "spurs" on either side of the cloaca. There are some other snakes that have them as well, but these two families are most often cited as the most primitive snake families left.
This is pretty far out of my area of expertise. And the evidence for the evolutionary biology is pretty far from exact. The taxonomy on allot of the famalies, genera, and species of reptiles change frequently, and there are allot of theories on the exact relationships.
For example, the green tree python is now most commonly known by the scientific name Morelia viridis, and some biologists claim the animals on the Aru islands are a separate species altogether, Morelia azureus. For a long time they were known as chondropython viridis. And there are subspecies of M. viridis recognized on mainland Australia. That whole debate could go on for days. And that is just a debate on species and subspecies currently in existence.
Did snakes descend from monitors? Did monitors and snakes descend from the same ancestor in separate directions? Are monitors just a more recent example of convergent evolution? There are no straight answers. And allot of theories. Some become commonly accepted, but there is very little hard evidence for exactly how they evolved. Someone else could say "this is exactly what happened", but I think it is still up in the air.
Not that I have ever put any thought into this or anything. That is one of the reasons I like all of the reptiles of the Indo-Australian islands. It is an amazing reprisentation of convergent and divergent evolution. All of the subspecies of carpet pythons, Morelai spilota sp., in themselves, are amazing. Plus all the other python species. The monitor lizards, the komodo dragon, Varanus komodoensis, the perentie, Varanus giganteus, the crocodile monitor, Varanus salvadorii, and the black tree moitor, Varanus beccarii, just to name a few,are fascinating.
I could bable on for days, but this is pretty far from pet related...