There are many mythical stories related to the orgin of Raksha Bandhan. So let's see a few stories related to the orgin of Raksha Bandhan.
credit: third party image reference
1) Demon king Bali once asked Lord Vishnu to stay with him in his palace to which Lord Vishnu agreed. Goddess Lakshmi the wife of Vishnu wanted him in Vaikuntha . So Goddess Lakshmi tied a cotton threat to the demon Bali and made him her brother and then he asked her what she wants. So she asked Bali to send Lord Vishnu with her to Vaikuntha to which Bali agreed.
credit: third party image reference
2) The other story is that Yama the brother of Yamuna went to see her after a long time . Yamuna was very happy to see her brother and tied him a thread with which Yama was pleased and asked Yamuna what she wants. Yamuna told Yama that she wants see him for ever so Yama made Yamuna immortal and granted her wish.
credit: third party image reference
3) Once there was a war between Lord Indra and demon king Bali . This war took place for long period so Sachi the wife of Indra tied a cotton thread to Lord Vishnu. Then Lord indra defeated Bali.