Raksha Bandhan is based on the legend that the gods were having a war with the demons when the latter seemed to have the upper hand. Then God Indra sought help from his wife, Indrani. She tied a piece of silk around his wrist to ward off the evil demons. With the silk around his wrist, Indra beat back the demons and got back his home in Heaven.
Another legend says that Raksha Bandhan was a ritual followed by Lord Yama (the Lord of Death) and his sister Yamuna, (the river in northern India). On every "Shravan Purnima", Yamuna used to tie a sacred thread (Rakhi) to Lord Yama to bestow immortality. Yama was so moved by the serenity of the occasion that he declared that whoever gets a rakhi tied from his sister and promised her protection, will become immortal.
Around the 3000 BC when the Aryans settled in India, they brought with them this festival of Raksha Bandhan wherein a yajna would be performed before the men left for the battlefield and the womenfolk would tie a thread on their wrists as a sign of protection and also as a reminder that they were the protectors of the honour of the clan.
During the freedom struggle there were women who tied rakhis and sought promises from men that they would fight for the country’s freedom. As one story goes, after King Porus' wife tied a rakhi on the mighty Alexander’s wrist, the latter who was then engaged in a fierce battle with the former’s husband, relented and the battle ended in a treaty. The importance of rakhi moved on from battlefields to personal relations reflecting the bond of affection. Friends also tie rakhi to show their togetherness and close bond.
In Indian history there are several instances where the Hindu queens, especially the Rajput and the Maratha, have tied rakhis to the Muslim kings seeking their protection, which the kings provided despite the differences in their religion and beliefs. Of special significance is the instance when Rajput queen Maharani Karnawati sent a rakhi to Humayun to protect her from the Sultan of Gujarat who threatened to capture her kingdom. Humayun was aware of the significance of rakhi in the Hindu community, so he immediately accepted her request to protect her. Humayun was advancing towards Bengal to further the boundaries of his territory but on receiving her missive, he immediately turned back.