The children’s literature that was written prior to about 1900 is generally darker, more violent and threatening than what came after. Struwwelpeter anyone? We decided at some point that these themes were no longer fit for children despite generations having been raised with it. That’s probably the Victorian era, when childhood is said to have been “invented.”
TL;DR heavily moralistic stories are probably more relevant in a society where you're commuting to a factory at 9 or 12, vs modern society where your education continues into the mid 20s for many and the 5 or 6 year degree being more common than 4 these days.