OK, here is a very, very brief summary. I left some stuff out that is not relevant to the drama because Ao Ge's and Xiu Yan's story is very complex in the books:
Ao Ge and Xiu Yan are twins and born in the ancient, ancient world when the true gods were still around. Ao Ge was destined to be the Heavenly Emperor and Xiu Yan was to rule the Ghost Realm (in the drama, it's called Youming Realm). (Aside: China is now forbidding the use of anything "ghost" or "demon", so you get changed names like here and The Moon Supreme Leader for Dongfang Cincang in Fairy and Devil. And Mingqi in this drama is the Devil instead of Ghost Lord).
There was a great war 60000 years ago. Ao Ge and Xiu Yan led thousands of soldiers to fight the demons. Xiu Yan had to sacrifice himself to seal Minqqi. Half of his soul essence was with Minqqi and the other half scattered. Ao Ge managed to find these scattered essences and by giving up his position as Heavenly Emperor, he became two in the Underworld Realm. His twin lived in him and could come out when he was in that palace you see in the drama and it being a ghost realm, Xiu Yan walked freely to guide the dead to their incarnations. Out of that palace and realm, it was Ao Ge who was keeping his twin alive.
The power tributes the palace demanded from any visitors sustained Xiu Yan's soul but didn't heal him, and he was getting weaker and weaker and soon, he would be dead. Ao Ge wanted Ah Yin's core (or half of it) to heal his twin brother in exchange for two of Feng Yin's soul fragments.
You then see how this was played out in The Last Immortal and how the two brothers became two entities again. Hope this very short synopsis of their story helps.