I don't think most people know what the story really says.
Hans Christian Andersen is just messed up. Any actual story that I've read by Hans Christian Andersen (like the original story of "The Ugly Duckling") is just wrong. There was something wrong with the man. Everybody in his worlds is just horrible, horrible people (or animals in this case), except for the main character who's the best ever, and there's no middle ground. We're all saints or devils.
So most people know the general outline of the story of the ugly duckling. A duckling is born, it's super ugly, and it turns out it's a swan. This adaptation is probably fairly accurate to the original (except as wordy as this adaptation is, Hans Christian Andersen is a quite a bit wordier). The last five or so pages of the long book are where he finds out he's a swan. The rest of is just this poor cygnet going through horrific trials. It takes five pages for him to get born in the first place, and everybody mocks him, going so far as to bite and kick him, basically beating him up until he runs away. Then he's made fun of by a bunch of ducks. Some ganders come, and they get killed by hunters. The cygnet almost gets taken away by their dog, but he ends up in a farmhouse with a woman who's got a chicken and a cat. But he doesn't lay any eggs, so they make fun of him because he's not useful. Then he runs away again, and it's wintertime and he almost freezes to death, and gets taken in by a farmer and then escapes... An actual sentence from the book: "It would be too sad to tell of the loneliness and misery the duckling had to endure that long, hard winter as he sat out in the swamp among the reeds." As opposed to the horrible company of any other character in this book? Apparently the rest of the depressing book wasn't considered "too sad."
When he sees some swans early in the book, it says, "A flock of birds came out of the bushes. They were dazzling white, with long, limber necks. The duckling had never seen anything so beautiful.... He did not know their names or where they were flying to, but he loved them more than he had ever loved anyone before." When they return in the spring, he says, "I will fly over to those royal birds, and they will beat me because I, who am so ugly, dare to come near them. Still, it is better to be killed by them than to be bitten by the ducks, pecked at by the chickens, kicked by the girl who takes care of the duck yard, and suffer the hardships of winter!" And then he goes over to them and literally says, "Kill me!" before he discovers that he's a swan. And then all kinds of people come by and go, "Oh there's a new swan in the swan pond, oh my god!" And the last sentence is, "He fluffed his feathers, lifted his slender neck, and from his heart there came a cry of total joy and contentment."
I really wish there was a story this famous that was not this blatantly about appearances. You can say it's a product of its time, but never once does it say that the characters who are mistreating the ugly duckling are wrong. The way that it has come into our popular consciousness does not include physically abusing ugly people.
The message is not, "It's okay to be ugly." The message is not, "Treat everybody kindly regardless of their looks." No, the message is, "Things which look ugly now will turn out to be pretty later." That's the best you can get out of this. I think people assume the story says something about true beauty being on the inside, but that's not in this book.
Who gets to decide what's beautiful? Because I would imagine that swans find cygnets beautiful. It's just that he's in the wrong company for his beauty to be recognized. Why do humans even think swans are pretty, and why does the ugly duckling give a fig whether humans think he's pretty?
It's clearly supposed to be a metaphor for something, but I'm not 100% sure what. I don't think I've ever really understood the moral of (or interest in) in the pop-culture version of the story.
There needs to be a version of this story where people stand up for the ugly duckling, or he stands up for himself, before he becomes a swan. Or he doesn't turn into a swan and he's just actually an ugly duck, and it's okay. It's okay to be ugly. I'm not saying that I'm like the most attractive person in the universe, but I'm fairly symmetrical. But there are children who are not pretty. There are children with physical disfigurements and their lives are more difficult because of that. For anybody with a physical disfigurement, their life is more difficult because they are not conventionally attractive. And this book does nothing for that. You kind of expect it to, but the story just ends up uglier than any duckling could ever be.