Sydney Carton's famous last words are technically never spoken aloud to any other character. It might even be more appropriate to call them his last thoughts. The narrator observes that a woman about to be executed asked to be allowed to write down her final thoughts before being killed, and the transcription of Carton's final words are actually what he was thinking before dying and what he would have put down on paper had he been given the chance.
At any rate, Carton's last testament regards the future. He sees the revolutionaries eventually consumed by their own hate and paranoia, themselves dying under the guillotine's blade. He sees Paris restored to civility and peace. He also sees the Darnays naming one of their children in his honor and the child growing up to become the kind of man that Carton could have been but never was because of his alcoholism. He sees Dr. Manette respected, loved, and in peace as he passes away. He sees Charles and Lucie dying of old age, faithful to one another until the very end. Finally, he closes out his life with this famous statement:
It is a far, far better thing that I do, than I have ever done; it is a far, far better rest that I go to than I have ever known.
In essence, Carton is saying that his act of sacrifice has redeemed the waste that has been his life. He does not fear death because he knows that he is dying for a good cause and because he believes that he will find the ultimate peace in death.