Despite the title of this Mark Twain work (Pudd'nhead Wilson), the protagonist is clearly the female slave, Roxana. It is through her eyes that we see the story, and she is the one who does the terrible deed which creates all the trouble in this novel.
We learn early in the story that Roxana is a mixed-race woman who has a son whose father was a white man; because of those genetics, her son, Chambers, can easily pass for white. In fact, he looks exactly like the white son (Tom) of her owner; the two boys looked so alike that Tom's father cannot tell the two boys apart. When it becomes clear that Roxana's master is going to send her "down the river" as a punishment for something she admitted to doing but did not do, she is afraid.
In her panic, she is desperate for her son to be safe and well, so she switches the boys. Her son is raised as a white man with all the privileges he would never have had as a the son of a slave; unfortunately, instead of becoming a fine man, this life of privilege allows Chambers (known to everyone else as Tom) to become spoiled and selfish. He is not a nice boy, and he grows into a gambling, drinking, thieving man.
In terms of Roxana, her great sin, she believes, is switching the boys, making an innocent white boy a slave without his consent or knowledge. She does feel bad about the consequences of her actions on Tom (now known as Chambers), but she tries to justify it this way:
“Tain’t no sin- white folks has done it! It ain’t no sin, glory to goodness it ain’t no sin! Dey’s done it- yes en dey was de biggest quality in de whole bilin’ too-kings!”
Of course she is right that many Negroes have been made slaves without their consent, but that does not justify her doing the same thing to an innocent child.
Roxana's punishment for that sin comes to her through the cruel and selfish actions of the very son she was trying so hard to save. When Chambers (known as Tom) gets himself deep in gambling debt which he cannot pay, his mother eventually offers to have him sell her for a year in order to get the money to clear his debt; after a year, he is supposed to buy her freedom and all will be well. That is not quite what happens, however.
While Roxana assumes her son (who now knows that he is a Negro and is mortified by the knowledge) will sell her into a pleasant position, he actually sells her literally "down the river." It is an expression which reflects the reality that conditions are worse for slaves in the South, and it is every Negroes' worst fear.
It had been imagined that she [Roxana] "would not know," and would think she was traveling upstream.
But Roxana has extensive experience with steamboating (as she made her living on steamboats for years until she eventually returned to town), and when she finally pays attention, she realizes that she has been sold "down the river" by her own son. That is when she says:
"Oh, de good Lord God have mercy on po' sinful me--I'S SOLE DOWN DE RIVER!"
This is her prayer to God, of course, but it is also her admission and recognition that she is now paying (being punished) for her great sin. Just as she figuratively sold a white boy down the river by making him a slave, now a boy assumed to be white has literally sold her down the river. It is her punishment from God, and only he can help her now.
Eventually Roxana escapes her awful situation; however, she does seem to be continually paying for that sin at the hands of the very son she was so desperate to save.