In "The Kite Runner," if Hassan was the illegitimate son of Baba, then who was Ali?
In the novel, Hassan was the result of Sanaubar (Ali's wife) and Baba's adulterous relationship. Since Sanaubar was already Ali's wife at the time Hassan was born, all the parties involved simply continued with their lives as if the affair never happened. This was presumably done to protect Baba's position in his Pashtun/Sunni Muslim community. After all, Sanaubar was a Hazara (like her husband, Ali), and Hazaras were Shia Muslims; it would have been unthinkable for a man of Baba's position to admit to an affair with Sanaubar, a member of a hated sect.
After Sanaubar left Ali, he continued to raise Hassan as his own son. In the middle of the novel, we learn Hassan's true paternal heritage from the conversation between Rahim Khan and Amir. Rahim Khan confessed to Amir that Ali had always been sterile and that Hassan was fathered by Baba. Amir's reaction was explosive:
"You bastards," I muttered. Stood up. "You goddamn bastards!" I screamed. "All of you, you bunch of lying goddamn bastards!"
"How could you hide this from me? From him?" I bellowed.
"Please think, Amir jan. It was a shameful situation. People would talk. All that a man had back then, all that he was, was his honor, his name, and if people talked... We couldn't tell anyone, surely you can see that." He reached for me, but I shed his hand. Headed for the door.
After he learned the truth about Hassan's parentage, Amir felt even more beholden to Hassan. He realized that both he and his father betrayed Hassan in their own ways. This terrible knowledge led Amir to fight for Sohrab's freedom as a form of redemption.