A cautionary tale is a story that is told to warn against a specific action or practice. To state that more positively, it is told to instill certain desired behaviors in the listeners/readers, or to guide them away from socially disruptive behaviors. A classic example of this might be the story of the scorpion and the frog, in which a scorpion begs a frog for a ride across a river, promising not to sting the frog because it (the scorpion) needs the ride so much. However, midway across, it stings the frog. When asked why, it says something like, "It is my nature."
In science fiction, "Frankenstein" is a classic cautionary tale: don't mess with forbidden knowledge/the origins of life, or your whole family will suffer.