Today's edition of La Repubblica informs us of the important fact that the original Pinocchio did not have a happy ending. In fact, it wasn't even called Pinocchio, but Storia di un Burattino (the story of a puppet), and it first appeared serially in a children's publication called Il Giornale per i Bambini (the children's newspaper). In it, Pinocchio is actually hanged to a tree at the end of the tale by the perfidious Cat with the help of the despicable Fox.
How Collodi (the Florentine Carlo Lorenzini) thought this was an acceptable ending for a children's story is a mystery. Although classic children's literature is filled with gruesomeness. But usually there is a happy ending after the gruesomeness. Perhaps it was insufficient knowledge of the wee folk, being that Collodi was both male and unmarried. What happened is that the Children wrote their Newspaper and told the author to change it. And he did, after which the book form contained the ending where Pinocchio repents of his sins like a good Catholic puppet, becomes a real boy and lives happily ever after with Geppetto.