Story of origin of sword in Hinduism is mentioned in the Puranas. Devas, or demigods, were constantly harassed by the demons (asuras). Fed up with this constant fighting, Devas asked Brahma for a solution.
To help the Devas, Brahma along with numerous other rishis performed a yajna in the Himalayas.
During the course of the yajna, a dreadful creature appeared from the havan kund (sacrificial fire). It had a thin and skinny body, which was deep blue in color. Its teeth were sharp and ugly looking. Although thin, it showed great strength and power.
When it moved around, the earth started trembling, huge waves appeared in the oceans, there were huge winds, trees started falling and meteors appeared in the sky.
Brahma then asked the powerful being to take the form of a sword and protect Dharma.