There's the legend, in that it was only brought up in one book outside of PS at the end of 2e and then outright ignored later on, is that Asmodeus really is the Persian/Zoroastrian God of Evil Ahriman/Angra Mainyu, and was banished by his counterpart Jazirian the God of Coatls (which I assume would make Jazirian the secret identity of Ahura Mazda). But that Zoroastrian backstory is one story how good and evil of the lawful side came to be.
I think there's a similar story for Chaos where all chaotic beings once were part of the forces of the Queen of Chaos including the Obyrith Demons and Planar Eladrin like Queen Morwel. But after that primal conflict some like Queen Morwel became Celestials, and others went to the Abyss.
There's a lot of contradictory stories out there about the planes, but many of them have some form of the truth.