The impression I got was that Jiraiya turned down the offer of becoming hokage in favor of Minato. Orochimaru was once a good man before he became obsessed with immortality & knowledge, and was once Sarutobi's star pupil.
Orochimaru was a villain in part one but that was over once he was defeated by Tsunade allowing her to surpass the previous hokage by defeating him. But he couldn't be killed because he was the one that was going to train Sasuke, and the reason he leaves the village. So he stays around till he is defeated by Sasuke once he done training him, and sealed by Itachi once even his power was no longer needed. So that was the end of him.
However during the war arc someone got the bright idea that it would be great if some revived the old hokage, and had them join the good guys. However, not many people knew the resurrection technique. They couldn't use Kabuto because he needed to be defeated by Sasuke for his flip-flop again. So they brought back Orochimaru who knew the jutsu, and conveniently knew how to revive the hokage without grave-digging. So despite being a villain the was still evil, as well as still desiring Sasuke's body, but its the end of the world so he is helping the good guys. So he becoes a bored aid to Sasuke that help save the world, and because the story ends before they can deal with him. He is let go.
Then with the new series coming out they needed a third team member (clearly the lee clone was not good enough.) So an executive decision because orochimaru is popular, kishimoto out of spite, or someone thought it was a great idea; I don't know. Someone decided that Orochiumaru's son should be the third team-member allowing Orochimaru to remain relevant to the story. Though I doubt theme's were involved what so ever. Those were abandon with the rest of the story for Hinata.
I suspect the decision to do Boruto and to include his kid as character was made by this point and that was part of the reason Orochimaru was revived, if not the main reason. If they needed all the hokages Kabuto could have done it earlier and they could been broken free by say, Itachi, or some other ass pull. Coherence and internal consistent clearly hadn't been a big concern at that point.