Why might Twain continue to inflict the two frauds, Duke and King, on Huck and Jim past Chapter 31 in The Advenures of Huckleberry Finn?
This question calls for conjecture and opinion. We simply have to guess. For my part, I would guess that there may be two answers to the question of why Twain decided to continue with the characters of the Duke and the King, not allowing Huck to succeed in escaping from them when he tries for the first time.
Possibly, Twain simply liked these characters. The Duke and King are comical and easily create action. They also pose a direct challenge to Huck's conflicted loyalty, pressing Huck to finally come to a conclusion regarding his moral dilemma (to follow his own conscience or submit to the moral dictates of "society").
Possibly, Twain intended to end the story with a final conflict between Huck, Jim and the two rogues. Jim's fate is not necessarily central to the conclusion of Huck's narrative. This seems especially true in light of the several episodes where Jim plays no part in the narrative at all. Jim's freedom then is not necessary to the novel. Huck's freedom, however, is necessary and could be achieved through a final escape from or showdown with the King and the Duke.
As the narrative stands in its finished form, the King and Duke play little part in the action of the last third of the novel. They instead become absorbed into society at large, both symbolically and actually.