In his Letters, Tolkien never mentioned his reasons for killing Fili and Kili. Apparently it was a question that no one asked him, and likely not one that he had thought about in great detail. I think that their deaths probably were meant to show just how devastating the Battle of the Five Armies was. Since they had no part in Thorin's decision to double-cross the Men of Lake-town, and since the book gives no indication that he even knew of their deaths before he died of his wounds, I do not think that the deaths of Fili and Kili were intended as a punishment for Thorin's mistakes. They were his nephews, not his sons, so Thorin's bloodline was not extinguished by their deaths. Tolkien states that many Dwarves, both male and female, chose not to marry. Not having a direct descendant to rule after him would not have seemed problematic to a Dwarf king. In any case, Dain comes off as a much wilder character in the movies than he does in the books, where he apparently rules both his Iron Hills and Lonely Mountain kingdoms very well. Additionally, he was a cousin of Thorin's, not a stranger that Thorin had never met. Thorin trusted Dain and would not have been sorry to see Dain ruling Erebor.
Also remember that the Dwarves in the book have little to distinguish them as individuals. Fili and Kili are younger, related to Thorin, and have better eyesight. Otherwise, we have little information about them. People who have seen the movies are likely to be more attached to individual Dwarves, because Peter Jackson made a point of giving the movie Dwarves distinguishing features. But Tolkien's original readers were unlikely to be very moved by the deaths of Fili and Kili. Thorin was the only Dwarf to whom Tolkien gave a fully developed personality, and he is also the only one of the Dwarf casualties of the battle to receive a death scene. Fili and Kili's deaths are mentioned almost as an afterthought.