Orochimaru was originally a student of Hiruzen Sarutobi as part of a three-man team, consisting of himself, Jiraiya and Tsunade. Even at a young age, Orochimaru stood out as a prodigy — his talents, knowledge, and determination were considered by his sensei a prodigy only seen once in a generation.
During the Second Shinobi World War, Orochimaru and his former team-mates fought Hanzō, who gave them the title of Konoha's "Three Legendary Shinobi" as a reward for surviving their battle. On their way back to Konoha, they encountered three Amegakure orphans, who Orochimaru proposed to kill to put them out of their misery, but Jiraiya chose to train them instead.
According to Tsunade, Orochimaru had always been twisted, even back when he was a child. His sadistic attitude was presumably due to the death of his parents, which led him to study kinjutsu and eventually becoming obsessed with learning all ninjutsu. Jiraiya theorised that Orochimaru went down this path in an attempt to forget his painful memories. Sarutobi in particular had very high hopes for Orochimaru, often berating the clumsy Jiraiya and telling him he should be more like his team-mate. After becoming the Third Hokage, Sarutobi hoped that one day Orochimaru would succeed him. He eventually became Anko Mitarashi's mentor, teaching her ninjutsu and taking her, along with nine others, as a subject for the Cursed Seal of Heaven.
While Orochimaru's ambitions did include becoming theFourth Hokage, his eyes were set upon goals quite alien to the ideals traditionally associated with the title and emphatically embraced by his teacher. Hiruzen knew that "a shinobi's true strength will manifest when protecting something important", and the Hokage's role is to love and protect the people of the village as if they were a family. For Orochimaru, however, Hokage was nothing more than a potential conquest on the way to what truly interested him: power. This mindset influenced the image he had on people around him, with a young Ibiki Morino seeing him as "something inhuman in human form".
Over the years, he had been kidnapping his fellow Konoha shinobi and used them as human guinea pigs. He experimented on them to develop techniques that would grant him immortality, as he had already decided that he would settle for no less than to learn all of the techniques in the world (a task that would take much more than one human lifetime). When the many disappearances were finally traced to Orochimaru, Hiruzen knew that it was his duty to kill him. At the time however, Hiruzen was unable to bring himself to kill his prized student for whom he had such high hopes.Hiruzen had hoped to make his student see the error of his ways, but as more time passed, it became evident that Orochimaru was a lost cause. When Hiruzen finally retired years later he chose a student of Jiraiya's, Minato Namikaze, over Orochimaru as his successor, thus making Minato the Fourth Hokage. Realising that he had hit a dead end in his quest to become the ultimate being and therefore had nothing to gain from staying in Konoha, Orochimaru began to be less discreet with his actions.
Before Orochimaru defected, he kidnapped sixty children and injected them with the First Hokage's DNA, hoping to recreate the First's Wood Release techniques. Before he could finish his work he was forced to leave Konoha, but he believed all the test subjects to be dead. Yamato was the only survivor of the experiments, and had gained the use of the wood element. Orochimaru conducted similar experiments on Danzō, endowing the elder with the Wood Release and multiple Sharingan.
Orochimaru defected from the village and joined the elite criminal organisation of Akatsuki. His former team-mate, Jiraiya, tried to convince him to reconsider, but to no avail. Although the role Orochimaru played in Akatsuki is unclear, it is known that he was partnered with Sasori prior to his defection (the two apparently had great respect for each other when they were partners; Sasori also claimed that he and Orochimaru did a lot of good deeds when they were together in the organisation).
At some point, when the Kaguya clan attempted to destroy Kirigakure and were themselves destroyed instead, Orochimaru was on the outskirts of the village, watching and commenting on their foolishness. It is there that he met Kimimaro and, Kimimaro being the sole survivor, was taken in by Orochimaru, in the hopes of becoming his new vessel.It was around this time that Itachi joined Akatsuki after conducting the Uchiha clan massacre. Orochimaru saw his opportunity to gain possession of the Sharingan, and soon Orochimaru made his attempt to steal Itachi's body. Orochimaru tried to use his Living Corpse Reincarnation, but Itachi used his Sharingan to reverse it and cut off Orochimaru's left hand to prevent him from breaking the genjutsu, causing him to leave Akatsuki to acquire a new body. For Orochimaru's defection, Sasori developed a grudge, and sent abrainwashed Kabuto Yakushi to spy on him, however, Orochimaru undid the brainwashing and Kabuto became the loyal right-hand man of Orochimaru. He eventually founded his own village, Otogakure, to perform various experiments on his prisoners. Orochimaru had also searched for the Totsuka Sword, an ethereal sword, for all his life, unaware that it was in the possession of Itachi's Susanoo.
At some point, Orochimaru began researching the source of Jūgo's powers and uncovered the Ryūchi Cave, where he attempted to attain senjutsu, but failed due to his current body not being able to absorb natural energy.