While turtles start out in the fossil record with their shells more or less fully developed (around the Triassic IIRC), there are many other reptile lineages that show intermediate steps in armor development.
The pareiasaurs, which may be distant turtle relatives (or then again, maybe not), were the dominant large herbivores throughout the late Permian. Some forms lacked armor, but near the end of the late Permian two new families of predators took over that necessitated the evolution of heavy protection.
The gorgonopsids and therocephalians, which really weren't hugely different, were both products of rather gradual predator evolution. Compared to the previously dominant predator groups, both the therocephalians and gorgonopsids were faster and smaller. In fact, the gorgonopsids are often cited as the first terrestrial predators capable of a quick trot, so while their anatomy was not radicaly different from their parent groups, they were quite a bit more effective. In addition to greater mobility, both gorgonopsids and therocephalians have big canine teeth. In some gorgonopsids, especially species like
Inostrancevia the canines were comperable to the teeth of machairodonts that would stalk the Tertiary and Quaternary. It is thought that both gorgonopsids and therocephalians had elevated metabolic rates, and therefore greater appetites, and some therocephalian remains seem to indicate certain species were experimenting with venom (which would make them the first vertebrates to have done so).
In short, the pareiasaurs were suddenly up against stiff enemies. Some pareiasaurs evolved more and more elaborate armor plating, and suprise suprise, the larger gorgonopsids evolved longer fangs. It's possible that the thicker and more interlocking pareiasaur armor gave rise to turtles:
But then again, the armor may have just evolved in parallel. Still, gives you an idea of what might have caused it.
Edit
This is a gorgonopsian, in this case
Dixeya. Quite a mean hombre, gives you an idea of why the pareiasaurs needed armour so badly.