Shani which is a sanskrit word translated as Saturn, who is considered as son of Surya and Chaya as well as brother of Lord Yama. Being an ardent devotee of Lord Shiva, Shani was given a responsibility to punish or reward people according to their good and bad deeds.
When Lord Shani was in the womb of Chaya Devi, she failed to take care of her health and as a result the newborn baby was dark skinned and grossly weak. Seeing his son, weak and dark skinned which is opposite to Surya, he refused to accept him. Lord Surya decided to abandon both Shani and Chaya Devi.
To became powerful like his father Lord Shani sacrificed his childhood and did strict & hard penance to Lord Shiva. He became successful to impress Lord Shiva, Shiva boon him with the responsibility to punish or reward people according to their deeds.
After getting powers Shani Deva punished his father for insulting him and his mother. Later he punished everyone who disobey him with his deeds. According to Shani Siddhanta under Lord Shani’s powe, he could punish anyone with bad deeds and rewards anyone with good deeds including Gods, Demons, Naga and Humans. Nobody with the bad deeds can escape from the eyes of Lord Shani.
The reason behind the mustard oil reffering to Shani Deva is very deep. When Lord Rama made Rama Setu to reach Lanka, hanuman was responsible to take care of it. One day Lord Shani came and told him that he is the Powerful God and I want to test your power. Hanuman then refused to fight because he was meditating Lord Rama. But Shani wants to fight, then Hanuman caught him in his tail and moved it up and down. Which hurts lord Shani and he started bleeding.
When Hanuman set him free after his apology, Shani asked him for oil offering to reeduce his pain. Hanuman offered oil to Lord Shani and it became customary to offer oil to Lord Shani. According to Jyotish Shastra Lord Shani stays in every Rashi for 2.5 years and his effects started from 2.5 years before his arrival and lasts after 2.5 years of his departure. This became a cycle of 7.5 years known as Sadhe Satin.