Once Koshala was a great kingdom, & king Sagara was performing Ashwamedha Yagna. He lost the track of his sacrificial horse. He sent his 60 thousands sons to find the horse. They searched horse in every corner of earth & destroyed everything that came in their path. At last they reached to sage Kapila asharam & the saw the horse tied their. They made charges on the sage of stealing the horse. As a result of this offense to sage Kapila, All 60,000 of them were burned to ashes. King Sagara waiting for his sonsthen send his grandson Anshuman to whom sage Kapila said that only by the presence of sacred river Ganga would all of this 60,000 sons purified and delivered.
Many kings of the dynasty performed austere penance for getting Ganga but could not bring Ganga on earth.
As time passed, their curse multiplied & it started to even destroy the Koshala kingdom. And then king Bhagirathi spur into action and did penance for 1000 years & made Lord Brahma happy to send Ganga on earth. Now the force of river was so destructive that earth will not be able to hold it. For that Brahma told Bhagirathi to pray to Lord Shiva. After a year of penance Lord Shiva appeared & told Bhagirathi that his wish would be fulfilled. When Ganga was falling from heaven everybody was so afraid that everything would be destroyed. Ganga came forcefully. As it was going to hit the earth Lord Shiva captured her in his Jata matted hair. Ganga was helpless and was unable to come out of it. At this Bhagirathi prayed Shiva again & Lord Shiva released Ganga.
Ganga now flowed behind Bhagirathi giving liberation to all his ancestors. Before this, Bhagiratha also got her on the way to Varanasi. Varanasi is eternal abode of Shiva so to pay the homage to the city, Ganga decided to change course and flew Northward. The city is east facing boundaries laying between Asi & Varuna rivers. The direction of the sacred river Ganga is northward in city. In Indian culture a place where two rivers join is sacred so in Varanasi the numbers are three thus making it even more auspicious.