According to the legend, Dashanan Ravana was doing penance on the Himalayas to please Lord Shiva, he was cutting his heads one by one and offering them to the Shivling. After offering 9 heads, when Ravana was about to cut his 10th head, Bholenath was pleased and appeared to him and asked him to ask for a boon -
then Ravana asked for a boon to take 'Kamna Linga' to Lanka. Apart from the golden Lanka, Ravana had the power to rule in all the three worlds, as well as imprisoned many gods, Yakshas and Gandharvas and kept them in Lanka. Because of this, Ravana expressed his desire that Lord Shiva should leave Kailash and stay in Lanka, Mahadev fulfilled his wish but also put a condition.
He said that if you keep Shivling anywhere on the way, then I will stay there again and will not get up, Ravana accepted the condition, here all the gods got worried after hearing about Lord Shiva leaving Kailash, to solve this problem Everyone went to Lord Vishnu. Then Shri Hari composed the Leela. Lord Vishnu asked Varun Dev to enter Ravana's stomach through Achaman. Therefore, when Ravana came towards Sri Lanka with the Shivling, he felt a small doubt near Deoghar, in such a situation, Ravana went to make a small doubt by giving Shivling to a Baiju named Ahir. It is said that there was Lord Vishnu in the form of Baiju Ahir. Tired of the increasing load of Shivling,
Baiju Ahir installed the Shivling on the earth. When Ravana returned, he could not lift the Shivling even after lakhs of efforts. Then he also understood this leela of God and got angry, kicking the Shivling and then went away after sticking his thumb. Hiding there, Baiju was watching all this, he felt that this is the way of doing devotion to Baba ji, since then it became a routine for Baiju. One day Baiju was very hungry, when he went home, as soon as he put food in his mouth, Baiju remembered that today, Baiju did not worship Bhole Baba, leaving his food, Baiju went on a tour with sticks, this time as soon as Shivling was attacked. While doing this, Mahadev would have appeared,
Mahadev said, Baiju, I am very pleased with your devotion. On seeing Mahadev, Baiju fell at his feet and said Mahadev, I had seen Ravana, if I had done this, I felt that you would have been worshiped like this. Mahadev hugged Baiju and said Baiju you have worshiped me from the heart. From today onwards the world will know you as my highest devotee, your name will be taken before my name and this place will be famous as Baba Baijnath Dham (further improved to Baidyanath Dham).
After that the gods like Brahma, Vishnu etc. came and worshiped that Shivling. As soon as Shiva appeared, all the deities established Shivling at the same place and went back to heaven after praising Shiva. Since then Mahadev resides in Deoghar in the form of 'Kamna Linga'. Here Brahma, Vishnu etc. Gods came and worshiped that Shivling. According to popular belief and folk belief, this Vaidyanath-Jyotirlinga is going to give desired results.
Jyotirlinga
As per Shiv Mahapuran, once Brahma (the Hindu God of creation) and Vishnu (the Hindu God of preservation) had an argument in terms of supremacy of creation. To test them, Shiva pierced the three worlds as a huge endless pillar of light, the jyotirlinga. Vishnu and Brahma split their ways to downwards and upwards respectively to find the end of the light in either direction. Brahma lied that he found out the end, while Vishnu conceded his defeat.
Shiva appeared as the second pillar of light and cursed Brahma that he would have no place in ceremonies while Vishnu would be worshipped till the end of eternity. The jyotirlinga is the supreme partless reality, out of which Shiva partly appears. The jyothirlinga shrines, thus are places where Shiva appeared as a fiery column of light.
Originally there were believed to be 64 jyothirlingas while 12 of them are considered to be very auspicious and holy.Each of the twelve jyothirlinga sites take the name of the presiding deity - each considered different manifestation of Shiva.At all these sites, the primary image is lingam representing the beginningless and endless Stambha pillar, symbolizing the infinite nature of Shiva.
The twelve jyothirlinga are Somnath in Gujarat, Mallikarjuna at Srisailam in Andhra Pradesh, Mahakaleswar at Ujjain in Madhya Pradesh, Omkareshwar in Madhya Pradesh, Kedarnath in Uttarakhand, Bhimashankar in Maharashtra, Viswanath at Varanasi in Uttar Pradesh, Triambakeshwar in Maharashtra, Baidyanath at Deoghar in Jharkhand, Nageswar at Dwarka in Gujarat, Rameshwar at Rameswaram in Tamil Nadu and Ghushmeshwar at Maharashtra.

The Maa Parvati temple is tied up with the main temple, with huge red sacred threads which is unique and worthy of reverence, showing the unity of Shiva and Shakti. According to the stories narrated in the Shiva Purana, the holy Baidyanath temple resembles the unity of souls and thus fits marriage for Hindus.
The Matsyapuran narrates the place as Arogya Baidyanathitee, the holy place where Shakti lives and assists Shiva in freeing people from incurable diseases. This whole area of Deoghar was under the rule of the Kings of Gidhaur who were much attached with this temple. Raja Bir Vikram Singh founded this princely state in 1266. In 1757 after the Battle of Plassey the officers of the East India Company paid their attention to this temple. An English man, Keating was sent to look at the administration of the temple.
Mr. Keating, the first English collector of Birbhum, took interest in the administration of the temple. In 1788, under Mr. Keating's order Mr. Hesilrigg, his assistant, who was probably the first English man to visit the holy city, set out to supervise personally the collection of the pilgrim offerings and dues. Later, when Mr. Keating himself visited Babadham, he was convinced and forced to abandon his policy of direct interference. He handed over the full control of the temple to the hands of the high priest.
Adi Sankaracharya has praised Vaidyanath jyothirlinga in following verses
Poorvothare prajwalika nidhane
sada vasantham giwalrija sametham
surasuraradhitha padapadmam
srivaidyanatham thamaham namami
This states that Vaidyanath jyotirlinga is located at Prajwalika nidhanam (meaning funeral place i.e., chithabhoomi) in the North-Eastern part of the country. Deoghar is far located in east part of the country. Also Chidabhoomi indicates that, in olden days, this was a funeral place, where corpses are burnt and post-death ceremonies were performed.
This place could have been a center of tantric cults like Kapalika/Bhairava where Lord Shiva is worshipped significantly as smasan vasin (meaning, residing in crematorium), sava bhasma bhushita (meaning, smearing body with ashes of burnt bodies).
The Dvadasalinga Smaranam also mentions its location as the verse is Prachikam Vaidyanatham, i.e., Vaidyanatham is in east (prachi means east). Another version of Dvadasalinga Smaranam mentions its location in the verse Paralyam Vaidyanatham,i.e.,Vaidyanatham is in Parali.The names and the locations of the 12 Jyotirlingas mentioned in the distorted version of Dvadasalinga Smaranam are:
Saurashtre Somanathamcha Srisaile Mallikarjunam|
Ujjayinya Mahakalam Omkaramamaleswaram ||
Prajwalayam Vaidyanathancha Dakinyam Bheema Shankaram |
Setu Bandhethu Ramesam, Nagesam Darukavane||
Varanasyantu Vishwesam Tryambakam Gautameethate|
Himalayetu Kedaaram, Ghrishnesamcha shivaalaye||
Etani jyotirlingani, Saayam Praatah Patennarah|Sapta Janma Kritam pApam, Smaranena Vinashyati||
Thus the three temples claiming their shrines as 'real' jyotirlinga of Vaidyanath are Baidyanath temple at Deoghar, Jharkhand,Vaidyanath temple at Parli, Maharashtra and Baijnath temple at Baijnath, Himachal Pradesh.