What is Mary Shelley's purpose in ending the book, Frankenstein, in such a way?
In the end, Victor's death seems to be the inevitable consequence of never having learned from his mistakes. Although he gives Captain Walton a great deal of sound advice, of himself he says, "During these last days I have been occupied in examining my past conduct: nor do I find it blameable." Such a position, in light of the misery his creature felt and the murders this creature committed in order to achieve his revenge on Victor, is both arrogant and idiotic. Victor has, at various times in the text, admitted his guilt, but now -- in the end -- he fails to take responsibility for his part in the tragedies initiated by his experiment and his neglect of the creature he made. His death is, in a way, required by the text. There is nothing else for him to lose but his life.
As for the creature, unlike Victor, he does take responsibility and grieves for his sins and the lives that he took. He admits, "I am a wretch. I have murdered the lovely and the helpless [...]." He vows to collect his own funeral pyre and burn his body so that no one will ever see him and try to create another like him. He is in a position similar to Victor. Victor was the only companion he had, and after Victor's death, he is alone. He, too, has been brought so low that there is nothing else for him to lose but his life.
Thus, Shelley ends the book with the appropriate consequence for failing to take responsibility for one's actions as well as for choosing a life of violence and hatred. We may sympathize with the creature, but he did make a choice to respond to his experiences in this way. It can even be said that neither one of these individuals deserves to live.