Martha's clone originated in the cloning pool located in the ATMOS factory in 2009. It was originally a human blank slate until Martha was lured into the room by hypnotised UNIT troopers. Her specific genetic material was transmitted to it. The clone acted as the Tenth Doctor's assistant and link with UNIT. The real Martha lay in a trance state, connected to technology that transferred her memories to the clone. (TV: The Sontaran Stratagem)
"Martha" stopped UNIT's missiles from being launched at the Sontaran flagship in Earth orbit, at the risk of igniting the Caesofine gas that was being used to breed more Sontarans. The Doctor had noticed many differences between the clone and the original. She "smelled funny", though he did not inform the copy that he had guessed until she turned a gun on him.
When the Doctor disconnected the real Martha from the Sontaran technology, the clone began to die. The real Martha felt sorry for her and convinced her to tell them the nature of the unidentified component of the Caesofine gas emissions, clone feed, before she died. Even disconnected from Martha, she still retained at least some of her memories. This was what made her help the Doctor and Martha at the end. Before she died, she told Martha that she, Martha, had so many plans for her life and she should go out and do them. (TV: The Poison Sky)