Always loved how Sir Terry just said "to hell with the ending of the Little Match Girl, there is nothing just or good or happy or inspiring about her dying alone in the snow", and proceeded to give her the ending she deserved in his own version of the story.
Beyond the clear social commentary, there's also something poetic, and indicative of his genius, that he had his version of the actual embodiment of Death decide to find the loophole and, for that one time, bend the rules to prevent this particular tragedy from happening and let her live.
It also ties very well with the final message of the book, that even if bleakness and unfairness are undeniably real, you need to believe in things like hope, love, and justice for them to exist. And maybe also subtly suggests that, if it's in your hand, you can contribute a tiny bit to that actually happening.