The film was originally intended to end with Hiccup largely unscathed after the climactic battle. However, the directors decided that it would not feel believable that the heroes could defeat such a formidable foe like the Red Death Dragon without great cost. With that in mind, they decided to have the boy lose part of his left leg at the end of the battle in a deliberate parallel to how Toothless the Dragon lost his left tail fin earlier in the film. Whatever concerns about how parents would react to the hero of a family film being so maimed were settled in the film’s test screenings. Parents in the audience told the producers on their own accord that they approved of that story development and requested that it be kept in the final edit. In addition, the original book’s author, Cressida Cowell, praised this ending and considered it true to the spirit of her book. Furthermore, the scene originally had Hiccup alone as he comes to grips with his wound. However, when Steven Spielberg saw the original footage, he felt that Hiccup and Toothless’ interaction in the film’s final act had been reduced to something like a mere cowboy and his horse. So, he suggested that Toothless be with the boy in that particular scene so as to reinforce the idea that their companionship was far deeper than that.
(Source: filmtrivia, via theyarethatwhichweknow)