The Moonstone was once a part of a larger whole called the Lifestone Tree. The Lifestone Tree was an ancient collaborative effort by various alien races to create a team of champions to safeguard the galaxy. The tree was composed of relics various alien cultures had accumulated and were believed to be remnants from the Big Bang. The team was named the Chosen Eight of Fate. Ajes'ha, a Kree warrior and member of the team, possessed one of the eight Lifestones and her memories were archived within the stone. The Lifestone Tree was eventually shattered, causing many fragments of the Lifestones to pass through warp space and fall to Earth.
Karla Sofen eventually began subconsciously tapping into the memories of Ajes'ha after she fell for Hawkeye, which drove her somewhat insane until I.S.A.A.C., the supercomputer of the Titan Eternals, cured her.
Originally there was only one moonstone but Karla Sofen got a second moonstone from her predecessor Lloyd Bloch's Counter-Earth counterpart Phantom Eagle after he went insane. Counter-Earth and its inhabitants were created by Franklin Richards. Having two gems greatly amplified Karla Sofen's power.
When she was put into a coma, Helmut Zemo seized the stones. Sometime later, one of the stones was destroyed by Songbird which resulted in Helmut Zemo being hurled backwards in time to relive his family's history. The single remaining moonstone restored Karla Sofen to consciousness.