How did the compound 莫 + 非 semantically shift to mean "can it be/is it possible + that"?
Both 莫 and 非 denote the sense of not.  The combination 莫非(a double negative) is a set phrase to mean 难道. It's often used to initiate a rhetorical question.
E. g.  莫非你不知道？ / 难道你不知道? // Don't you know it?