The point of all this is to try to find the rifts in the text that cannot be explained synchronically and then try to find a composition history that will make plausible sense of the text's diachronic development. Many of those rifts and problems were discovered centuries ago and "solved", at that time, by the creation of tales [midrashim], to explain the inconsistencies and/or bridge the gaps, and other similar explanations. Others have been discovered more recently by other scholars. Of course, we may disagree with the solutions put forward by all of those earlier scholars, but we can build on their well-honed skills in literary criticism.
Here's the story as it appears in Genesis 9:18-27
But this story has problems: When Noah woke how could he have known that his son simply saw him in an undignified drunken state? What happened to him, exactly? The term "uncover the nakedness" is used in Leviticus to mean having sex with someone, and both words appear here (with grammatical differences). Bruce Louden et al have (rightly) noted the connections with Hesiod, and propose that originally the story concerned castration. He is surely right, but whether the switch from castration happened at a literary stage or a pre-literary, oral stage, of transmission is unclear and there is no evidence of castration in text as we have it. Talmudic Rabbis proposed one or other of these explanations (b. Sanhedrin 70a). David M Carr doubts either, since in v. 24 the issue of seeing the father's nakedness is clearly taken literally. But I think the diachronic analysis explains this (see below). But there are other anomalies: Why is Ham is described as the youngest son, when he elsewhere is always the middle son. Why are we told that Ham is the father of Canaan in 9:22 when we had already read this in 9:18? Why is it that Ham is the son who disrespects his father but it is his son Canaan who is cursed?18 And the sons of Noah who went forth from the ark were Shem, Ham and Yaphet. And Ham was the father of Canaan. 19 These three were the sons of Noah; and from these the whole earth was peopled.
20 And Noah, man of the ground, began [?..] and he planted a vineyard; 21 And he drank of the wine, and became drunk, and lay uncovered in his tent. 22 And Ham the father of Canaan saw the nakedness of his father and he told his two brothers outside, 23 so Shem and Yaphet took a garment, laid it upon both their shoulders, and walked backward and covered the nakedness of their father; their faces were turned away, and they did not see their father's nakedness.
24 And Noah awoke from his wine and knew what his youngest son had done to him, 25 and he said:
“Cursed be Canaan - a slave of slaves shall he be to his brothers."
26* And he said:
"Blessed be the YHWH the god of Shem - and let Canaan be his slave.
27 God enlarge Yaphet - and let him dwell in the tents of Shem - and let Canaan be his slave."
Here's what I (at this moment) think is the best diachronic explanation for these discrepancies that I can think of.
(1) The earliest version - Canaan's wicked act and the curse it earns him:
The first verse 9:18 is actually the last verse of the genealogy of Noah, and is a sequel to Genesis 5:29. Some commentators (incl. Louden) assume that the text has been changed to Canaan from Ham, and the curse similarly amended. But it seems to me (and Carr is of the same opinion) that the curse against Canaan is the very raison d'etre of the story, and it must therefore have been the earliest version.18* And the sons of Noah were Shem, Yaphet and Canaan.
20 And Noah, man of the ground, began [..?..] and he planted a vineyard; 21 And he drank of the wine, and became drunk, and lay uncovered in his tent. 22a* And Canaan saw the nakedness of his father [....?]
24 And Noah awoke from his wine and knew what his youngest son had done to him, 25 and he said:
“Cursed be Canaan - a slave of slaves shall he be to his brothers."
(2) The "bowdlerised" version:
Here, by adding Canaan's two older brothers in verse 24, Canaan's crime is diminished to literally looking at the nakedness of his father without doing anything about it - disrespect - unlike the brothers, who cover him up, averting their eyes. The two brothers receive two-phrase blessings that parallel Canaan's curse. (I've also included the speculative reconstruction that it was originally the tents of Shem that were blessed, which was later overwritten. See below).18* And the sons of Noah were Shem, Yaphet and Canaan.
20 And Noah, man of the ground, began [?..] and he planted a vineyard; 21 And he drank of the wine, and became drunk, and lay uncovered in his tent. 22 And Canaan saw the nakedness of his father,
And he told his two brothers outside, 23 so Shem and Yaphet took a garment, laid it upon both their shoulders, and walked backward and covered the nakedness of their father; their faces were turned away, and they did not see their father's nakedness.
24 And Noah awoke from his wine and knew what his youngest son had done to him, 25 and he said:
“Cursed be Canaan - a slave of slaves shall he be to his brothers."
26* And he said:
"Blessed be the <tents (אהלי)> of Shem - and let Canaan be his slave.
27* God enlarge (yapht - יַפְתְּ) Yaphet - and let Canaan be his slave."
(3) The Post-Diluvian version
The above may involve different amendments, telescoped. In any case at this stage the story is linked to the well known (Priestly) version, in which the sons of Noah were Shem, Ham & Yaphet are the fathers of post-diluvian mankind. Ham is therefore made the father of Canaan and he is the perpetrator of the wicked act, rather than Canaan, who is now Noah's grandson. An additional clause is added to Yaphet's blessing, which refers back to the tents of Shem in the previous line. What does Yaphet dwelling in the tents of Shem mean? Wajdenbaum & Gmirkin argue that this must refer to Alexander's conquests - and they may be right. But "dwelling in the tents of" is not the most obvious turn of phrase to evoke imperial conquest, and the allusion may be to some other, less dramatic situation.18 And the sons of Noah who went forth from the ark were Shem Ham and Yaphet and Ham was the father of Canaan.
19 These three were the sons of Noah; and from these the whole earth was peopled.
20 And Noah, man of the ground, began [?..] and he planted a vineyard; 21 And he drank of the wine, and became drunk, and lay uncovered in his tent. 22 And Ham the father of Canaan saw the nakedness of his father ...
And he told his two brothers outside, 23 so Shem and Yaphet took a garment, laid it upon both their shoulders, and walked backward and covered the nakedness of their father; their faces were turned away, and they did not see their father's nakedness.
24 And Noah awoke from his wine and knew what his youngest son had done to him, 25 and he said:
“Cursed be Canaan - a slave of slaves shall he be to his brothers."
26* And he said:
"Blessed be the <tents (אהלי)> of Shem - and let Canaan be his slave.
27 God enlarge Yaphet, - and let him dwell in the tents (אָהֳלֵי) of Shem - and let Canaan be his slave."
(4) The penultimate version (part of Gen 9:26 only):
Here "tents of" (אהלי) becomes "God of" (אֱלֹהֵי) by means of the transposition of two letters. It's unclear whether this was a scribal error, or the scribed intentionally changed it, thinking that he was correcting the defective version he was copying."Blessed be the God (אֱלֹהֵי) of Shem
(5) Final version (part of Gen 9:26 only):
The name YHWH added (part of a redactional tendency repeated throughout Genesis 1-11)"Blessed be YHWH the God of Shem
I have just now come across a very interesting essay by David Frankel (whose approach I am certainly familiar with) Noah, Ham and the Curse of Canaan: Who Did What to Whom in the Tent? - which independently agrees with the division between 1 & 2 above. (And in note 22 he references the notion that the three sons were originally Shem, Japhet & Canaan.) However, he has an even more radical take on it, and believes that originally the father abused by Canaan was in fact Ham, and that the story was only later transferred to Noah. There are a number of reasons why I am not convinced by that, attractive though it is in some respects. If the drunk Noah story was in fact earlier than the Ark Noah, then his objections to the notion of such a story being originally part of the entire Noah narrative disappears. In any case I suspect that those same objections would have militated against the transfer of the story from Ham to Noah, as he proposes, as the ideological "benefits" of making this a Noah story seem meagre.