Rowling always planned to have Hagrid carry Harry across the battlefield, supposedly dead, at the end of the final novel. Although he may have seemed like a natural character to kill off, it was this ending that actually kept Hagrid alive through the series – it was Hagrid who carried Harry into this magical world, so it would be Hagrid who would carry him back.