A legend concerning the sword (khadga) appears in the Shantiparva section of Mahabharata. Out of curiosity, Nakula, the fourth son of Pandu and the master of swordsmanship, had questioned the Kuru Grand sire Bhishma, on his arrowy death bed, as to which was the best weapon in all kinds of fighting. In his own personal views, Nakula thought the sword to be the most superior, since even on having lost one's bow, horse and the chariot, a skillful swordsman could still defend himself against the mace and spear wielders. Nakula further queried the Grand sire about the origin and purpose of the Khadga as well as about its first acharya or preceptor. Gladdened by these intelligent queries by Nakula, Bhishma related to him the complete Itihaasa of the Khadga or "divine sword" starting from its creation down to the present i.e time of Bharata war.
This passage mentions that sword was invented to prevent the invasion of Danavas. It was known as Asi and was a highly polished and sharp edged weapon. After the wars between Danavas and Devas, the sword and its usage was passed on to various tribes like the Rishikas, the Yakshas, the Ikshwakus and it finally came to the Lunar Dynasty of kings starting with Pururavas Aila. From Puruavas it passed through Ayus, Nahusha, Yayati, Puru, Amurtarya, Bhumisaya, Dushmanta, Bharata, Ailavila, most of them the kings in the line of Pururavas. From Ailavila, it reached Dhundumara and from him to Kamboja. From Kambojas, the usage of sword spread to the Suryavanshi of kings like Muchukunda, Marutta, Raivata, Yuvanashwa, Raghu and Haryaswa. From them, it was taken by Sunaka, Usinara and finally by Bhojas and Yadavas. From Yadavas it spread to Sivis and to Pratarddana, Ashtaka, Prishadaswa and finally to the Bharadwajas including Drona. Drona taught it to Kripa and both of them taught its usage to Pandavas including Nakula .
Bhishma conversed with Nakula on the history of sword.
This passage mentions that sword was invented to prevent the invasion of Danavas. It was known as Asi and was a highly polished and sharp edged weapon. After the wars between Danavas and Devas, the sword and its usage was passed on to various tribes like the Rishikas, the Yakshas, the Ikshwakus and it finally came to the Lunar Dynasty of kings starting with Pururavas Aila. From Puruavas it passed through Ayus, Nahusha, Yayati, Puru, Amurtarya, Bhumisaya, Dushmanta, Bharata, Ailavila, most of them the kings in the line of Pururavas. From Ailavila, it reached Dhundumara and from him to Kamboja. From Kambojas, the usage of sword spread to the Suryavanshi of kings like Muchukunda, Marutta, Raivata, Yuvanashwa, Raghu and Haryaswa. From them, it was taken by Sunaka, Usinara and finally by Bhojas and Yadavas. From Yadavas it spread to Sivis and to Pratarddana, Ashtaka, Prishadaswa and finally to the Bharadwajas including Drona. Drona taught it to Kripa and both of them taught its usage to Pandavas including Nakula .