Harry Potter and the Deathly Hallows
by J.K. Rowling
In many ways, Teddy mirrors Harry. Harry was born near the end of the first war with Voldemort, and Teddy at the end of the second. Both have parents in the Order of the Phoenix, and both are orphaned as a result of Voldemort. The two of them are left with a godfather (Harry is Teddy's godfather). However, with Voldemort truly defeated after the second war, Teddy seems to have had a much happier childhood than Harry did. Unlike young Harry, Teddy has his godfather as a significant part of his life, and can grow up without fear that Voldemort will rise again.
After publishing Deathly Hallows, Rowling identified Teddy Lupin's story as one of the primary reasons that she wanted to include an epilogue:
To hear that Teddy Lupin – Lupin's son is obviously okay. That he has an ongoing relationship with Harry and that he's – he must be quite happy and he's got a very good-looking girlfriend because I think he's kissing in the epilogue his – Bill and Fleur's eldest daughter. […] [It's important] Because he's been orphaned. And I want – I want to show that he's okay.
And I want to show that because the world is a better place, he's having a happier – and then I started to cry. So obviously Teddy Lupin's very important to me. I just – yeah. I – having killed both his parents, I really wanted him to be okay. (source)