Shiva Dhanusha was created by Vishwakarma and he gave it to Lord Shiva. Lord Shiva used the this bow to fight Tripurasura (त्रिपुरासुर) and finally demon Tripura(त्रिपुर) was killed by this bow.
Fight between Lord Vishnu and Shiva
Once when devatas approached Lord Brahma and wanted to test, that who is more powerful among Lord Shiva and Lord Vishnu. Lord Brahma soon created enmity between Shiva and Vishnu, which led to fight among them.
तदा तु जृम्भितं शैवं धनुर्भीमपराक्रमम्।
हुङ्कारेण महादेव स्तम्भितोऽथ त्रिलोचन:।। – Ramayana, Balakanda chapter 75 verse 17
Lord Vishnu with his power made the Shiva’s Dhanusha ineffective and seeing this Lord Shiva become motionless.
Devatas declared Lord Vishnu as more powerful in this fight. Lord Siva, filled with anger gave away his bow and arrow in the hands of Rajarshi Devarata (देवरात), who belonged to Videha ( देवरातस्य राजर्षेर्ददौ हस्ते ससायकम् – Ramayana 1.75.20 )
This is how this Shiva Dhanusha become a property of Videha kingdom, where latter King Janaka was born.