Why does Huck risk his own safety to thwart the duke and dauphin in chapter 27?
By chapter 27 in The Adventures of Huckleberry Finn, Huck was all too familiar with the ways in which the duke and dauphin operated, and he recognized that they were plotting to rob the bereaved Wilks sisters of their inheritance money. Huck liked and felt sorry for the sisters, who had lost their brother and who were opening themselves up for a greater loss at the hands of the imposters, and he decided he must prevent the duke and dauphin from carrying out their plan.
I got to steal that money, somehow; and I got to steal it some way that they won't suspicion that I done it. They've got a good thing, here; and they ain't agoing to leave till they've played this family and this town for all they're worth...I'll steal it, and hide it; and by-and-by, when I'm away down the river, I'll write a letter and tell Mary Jane where it's hid.
Huck had a conscience and he followed its leading at various times throughout the book. Particularly when the king sold the "niggers" down the river the day after the funeral, Huck deeply felt for those who were suffering and was pleased that he had been able to arrange things so that the sale would soon be invalidated.
I reckon I couldn't a stood it all but would a had to bust out and tell on our gang if I hadn't knowed the sale warn't no account and the niggers would be back home in a week or two.