Sagara was a King in the solar dynasty of Ikshwaku. He propitiated Srihari by performing many Aswamedha yagnas. A consecrated horse was released as a prelude to the sacrifice. Indra, feeling insecure (The title of Indra accrues to a person who performs a hundred Aswamedha yagnas) steals the horse and hides it away.
Sagara asks his sons to find the horse to complete the sacrifice. The proud sons of Sagara, dig the earth all around in search of the sacrificial horse. (They dug out huge tracts of land which later becomes the ocean - hence called SAgara). In the north-easterly direction, they find the horse beside the divine sage Kapila, who was deep in meditation. They shout -- "Here is the thief who stole the horse!" They rush towards him with weapons. The sage Kapila opened his eyes. Deprived of their own good senses by powerful Indra, the sons of Sagara brought upon their own death by offending sage Kapila. They were instantly reduced to ashes. (It is not proper to say that they were killed by the wrath of sage Kapila, an embodiment of pure satva.)
Sagara commands his grandson Amshuman (son of Asamanjasa), to find the horse. He follows the path dug out by his uncles and discovers the horse near the heaps of ashes. Amshuman beholds sage Kapila (the Lord himself in the garb of a sage), and glorifies him. The divine sage Kapila blesses Amshuman: "You can take the horse back to your grandfather Sagara to complete the sacrifice, my child! And these uncles of yours, lying in ashes here, will be redeemed with the heavenly water of the Ganga." Amshuman, after paying respects to Kapila, returns with the horse. The yagna was duly completed.
Sagara crowns Amshuman as king. His efforts to bring the Ganga did not succeed. His son, Dilipa's efforts also fail to bring the Ganga down to earth.
Dilipa's son was Bhagiratha. He resolves to bring the Ganga to earth. He performs austerities and meditates on the Ganga. Ganga reveals herself in person and agrees to descend to earth, "But somebody must sustain my force as I come down, otherwise, I shall pierce through the hard crust of the earth, and enter Rasatala (the subterranean sphere). Further, I am not inclined to enter the terrestrial region. People would wash away their sin into me. Where shall I wash that sin, O Bhagiratha?"
Bhagiratha replies, "Lord Shiva will bear your force. And the pious souls who have given up all attachment shall wash away your sins, when they bathe in your waters." He sets off on a penance again to propitiate Lord Siva with his austerities. In a relatively less time, Bhagiratha pleases Lord Shiva (Ashutosh-who is easily pleased). The Lord accepts to bear the force of Ganga's descent. Shiva cautiously bears Ganga (purified by the hallowed foot of Lord Hari) on his matted locks, and lets it down to flow. The royal sage Bhagiratha, riding a chariot as swift as the wind, leads the river to the spot where the ashes of his ancestors lay. Bathed by the gushing waters, the ancestors of Bhagiratha were thus redeemed of all sins.
It took the consolidated penance and austerities of three generations of the Ikshwaku dynasty for Ganga to flow on earth.
Ganga represents Gnana, which has to borne by the Jeeva on his head.
(A more detailed account of the trials which Bhagiratha faced, and how he overcame them all through sheer persistence, is described in the Valmiki Ramayana).