Is there a specific or related word for when a story illustrates the doing of bad and unlawful things to reveal a moral value beneath it? For example- a story about a person committing suicide and showing that if anyone had talked to the person, they wouldn't have committed suicide. Or a person with a mental disorder who didn't receive any help from others and was driven insane. I would appreciate any words to describe such a story or an event, thanks!
Not a single word but it's usually called a cautionary tale
a story that gives a warning
A cautionary tale is a tale told in folklore, to warn its listener of a danger. There are three essential parts to a cautionary tale, though they can be introduced in a large variety of ways. First, a taboo or prohibition is stated: some act, location, or thing is said to be dangerous. Then, the narrative itself is told: someone disregarded the warning and performed the forbidden act. Finally, the violator comes to an unpleasant fate, which is frequently related in expansive and grisly detail.
I would go with the more general dictionary definition. I'm not conviced that the tale has to come from folklore although of course it may.