When we see the old Madara talking to Obito after he was found, we can see that his right part of the body is destroyed and replaced with that artificial, Hashirama cells included "body", and we can also see that his face is in a pretty bad shape, too, but he's got his right Sharingan. How it happened, that his right eye came out harmless after that incident?
There's no actual reason given. It was stated that "Madara managed to save his eye".
It was also half-implied that his Mangekyo was awakened for a brief moment and allowed him to slip through the rocks (Madara said something similar to that when Obito awoke for the first time).
I think it's a plot hole. If you think that the Mangekyo was awakened for a moment, since we saw when he really awakened the Mangekyo, it may be a healing technique that he used to save just Obito's right eye, not his entire body. But I can't imagine his Sharingan being the savior because in that case Obito could have managed to slip through the rock with his entire right part of his body.