A turtle has a shell because it provides it with protection. Almost certainly the original and most widespread role of the turtle shell is protection from predators, something that’s especially useful given the slow, careful foraging styles of most turtles. Different types of turtles have different types of shells which all provide benefits in their own ways. All turtles have some types of shells, but there are big differences in the protection those shells provide. Some turtles, such as the American and Asian box turtles, have hinges on the lower shells which allow them to go inside their shells and then close up the ‘doors,’ front and rear. Some turtles have special shells that allow them to bring their head, arms and legs into their shells for complete protection from predators, while others (such as the Leatherback Sea Turtle) have softer, more leather-like shells that allow them to swim deeper down into the sea!
In 230 million years, they have evolved to utilize very different habitats. They live everywhere on earth except the Arctic and Antarctic.