Lots of people have tried to explain this, but in my view, the real explanation lies in the fact that Noah's family had been chosen to reverse the mistakes of Adam's family, and that a key component of that was Ham having true and unchanging faith in his father, Noah.
But Ham saw Noah drunk and naked, and all he saw was sinfulness. He failed to see Noah, who was clearly a righteous man, from God's viewpoint. Instead, he mobilized his brothers to also see Noah as sinful.
If the purpose of the flood and the ark offering of 120 years of faith, was to separate Noah's family from the sinful world and sinful history, Ham's lack of faith and sinful heart evidenced that he was NOT cleansed (circumcised in heart).
One might come up with all sorts of ideas and theories, but consider: why on earth is Noah's family such a key story in the scripture? These details are there because they reflect something very important about how God works to restore the relationships and reverse the mistakes of the sinful past, to prepare us to receive and unite with Christ.
To understand the sin of Ham, in my view, one has to grasp the position of Noah's family, their mission and role, and what God requires of us in order to restore humanity via Christ, the True Adam.
But to understand that, we need to understand the purpose for the creation of humanity (Adam), the purpose of the angels, the dynamic between Lucifer and Adam that led to the Fall, so that we can grasp how Jesus reverses that.
The dynamic behind the Fall is this: God created humanity as his children, while all the angelic realms were created as 'servants'. God bless Adam to have dominion (governance) over the entire world, including the angels. Lucifer, enamored of his own brilliance and intellect, was unable to accept Adam. He thought he knew everything much, much better than the immature Adam, and became jealous of the love that God had for Adam.
This became Lucifer motivation of getting closer to Eve and seducing her. He believed if he could successfully seduce her to eat the fruit, he would win her love that Adam was destined to receive. (Eve being created as Adam's object of in love, just as Adam himself was created as God's object of love).
In moving to seduce Eve to eat the fruit, Lucifer himself became twisted and fell into the position of Satan. By seducing Eve to eat the fruit, and through here, seducing Adam to eat the fruit, Lucifer murdered Adam and Eve spiritually. (God knew this was possible, which is why God gave the commandment not to eat to Adam; he knew that if something went wrong, it would be Lucifer going off track.)
The dynamic between Lucifer and Adam is key. (This dynamic appears again and again and again in different forms throughout the Bible.) Lucifer was the elder being. Adam was the younger. The elder failed to humble himself to the younger, even though the younger was created to be the king of the universe, and the Lord of all creation (which includes Lucifer).
Before God can send the new Adam, Jesus, he needs humanity to at least symbolically reverse the mistake of Adam. Lucifer's mistake was arrogance, but Adam's mistake was lack of faith or disbelief (in God and God's word).
To reverse the mistake of Adam and the mistake of Lucifer, symbolically, God had Abel and Cain both make an offering. He accepted Abel's offering by rejected Cain's offering, why?
Because Abel - the younger brother - was symbolically in Adam's position (the younger being) re: Lucifer.
More importantly, the fallen Adam was a divided being now, with Godly nature, inherited from God, but now also fallen nature, inherited from Satan. So did God separate the good and evil in Adam by making one sone represent good and one represent evil? It appears so. The scriptures are replete with examples of how separation of good and evil is a core requirement for God to work via his chosen champion(s).
So Cain - the elder brother - was put into the position of Lucifer (the older being) who failed to humble himself to Adam - relative evil. Lucifer should have humbled himself to Adam and accepted Adam as his rightful conduit to God, because Adam was created as God's son.
What happened? Cain was even told by God that his task was to overcome evil. If Cain humbled himself to Abel, and asked Abel "hey, how come God accepted your offering? Help me make an offering that God will accept" he would have done what Lucifer could not, and symbolically, this would have resulted in Cain being separated out from Lucifer's dominion, and the unity between Cain and Abel would have symbolized that Evil had submitted to Good within Adam.
However, Cain could not overcome his feelings, and murdered Abel, thus repeating the very mistake of the Fall, and solidifying Lucifer's grip over Adam's whole family.
God then searched for someone who could reverse THIS mistake as well. Coincidence that Noah was chosen by God after 10 generations?
Noah's family stood in the position of being a substitute for Adam's family. Noah was a man of faith. He made an offering to God (building the ark in faithfulness for an extended period of time). Thus, Noah symbolically reversed the mistake of Adam - faithlessness. So now Noah symbolically restored Adam's position, and Noah's sons stood in the position to reverse the mistake of Adam's son - Cain who killed Abel.
Adam had three sons. Noah also had three sons. Coincidence? I don't think so.
Problem is, in Adam's family Abel himself was successful in the offering, and was able to stand in the position of Adam (the key position) in relation to Cain, in the position of Lucifer.
Ham, Noah's second son (the younger) had to also be able to stand in the key position of Adam in relation to his elder brother, Shem, who was to stand in the position of Cain towards Abel, and Lucifer towards Adam.
After Noah successfully made the offering, kept faith in God for 120 years, and saved the life of his entire family, Ham (and all Noah's sons) should have have absolute faith in his father, that God was using his father and that his father was a truly righteous man. (Just like Adam should have had faith in God, his father.)
The opportunity for the condition that Ham inherited Noah's faith and was also faithful to God came when Noah was drunk with wine and sleeping naked.
The world God had just cleansed was a world of debauchery, where the people were all engaged in sinful action. But not Noah or his family. Also, the offering of the ark symbolized the recreation of the entire world. So just as Adam and Eve were sinless after God created them, Noah's family should have been pure of the evil sinful thoughts that the fallen world had.
What happened? Ham actually saw his father, and was ashamed. He BELIEVED that Noah was acting sinfully. But the sin was in Ham's heart, not Noah's. Ham recruited his brothers to ALL disbelieve in Noah and see Noah as sinful, and they covered him up.
What this means was that Ham actually disbelieved in his father. The faith of Noah was thus NOT inherited by Ham, and so Ham could not stand in the position of the faithful Abel in relation to Cain, or in the key position of Adam in relation to Lucifer. Even though Noah had labored in unchanging faith towards God for 120+ years, when Ham expressed the sinful heart of disbelieving in his Father, Noah, Noah woke up and cursed him, because everything God had accomplished, including the 10 generations (for symbolic separation from evil) was lost.
That is why Noah cursed Ham. Ham had failed to establish the faith that would allow Noah's family to symbolically reverse the mistakes of Adam and Adam's family.
Immediately after the story of Ham's failure to have faith in Noah, we hear another more about Noah's family.
This may seem complicated, overly complex and maybe even far-fetched, but consider so much of the key people in the Bible in this light.
10 generations between Noah and Abraham? Coincidence? Abraham also has two sons - and elder (Ishmael) and younger (Isaac)? Coincidence?
Isaac also had two sons - the elder Esau and the younger Jacob. Esau wants to kill Jacob. Jacob flees, comes back and offers half of everything he owns to Esau, whose heart is melted and the two brothers - elder and younger - now unite. The younger son who obtained unity and submission from his elder brother is named Israel, and becomes the foundation on which God sends Jesus Christ later? Coincidence?
The elder brother - younger brother dynamic repeats many times in the scripture. Also, the need to have someone stand in that key position with faith in God - like Adam should have had - and someone else (an individual or people) stand in the position to humbly unite with and believe in that person in the key position - like Lucifer should have done.
That's because God needs humanity to at least symbolically reverse the mistakes of Adam and his family, as the condition for God to send Christ - who reverses Adam's failure by having complete and perfect faith in God, his Father, and who can stand as the sovereign over the universe that Adam was blessed to be but who handed that over to Lucifer by succumbing to Lucifer's temptation.
If one reflects on and re-reads scripture from this perspective, many things start to make sense, in my experience.
Why should this be? It's because sin and Satan always work via our lack of faith in God, his word, and distorted relationships. True relationships reverse the distortion of fallen and corrupted relationships.
When we united with Jesus, we put ourselves in the position of Cain to him as Abel, of Lucifer to Jesus as Adam. by loving and adoring and having faith in Jesus, we do what Lucifer could NOT do towards Adam. Thus, we cut ourselves off from Lucifer's dominion, and are 'reborn' as God's sons and daughters.
Anyway, that's my take on Ham. Ham was cursed because he failed tragically to unite with and have faith in his father, Noah. That faith was a necessary condition for God to bless Noah's family and lineage, and begin the process of preparing to bring Jesus. Ham's mistake delayed the establishment of the chosen people via the chosen family by more than 400 'biblical' years.
Don't be like Ham. Have faith in your Father, who is in heaven.