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 fulfill them. (TV: The Poison Sky)
While implanted with the memories of the real Martha Jones, due to her nature as a Sontaran clone, she was primarily loyal to advancing the Sontaran cause. The clone was also a good enough actor to fool all but the Doctor who could tell the difference due to inconsistencies unnoticeable by regular humans.
Despite her programmed loyalty to the Sontarans, the clone's possession of the real Martha's memories made her susceptible to divided loyalties. Using the clone's memories of her life, Martha was able to get the clone to help save the people Martha and by some extension her clone cared about. At the end of her life, appearing to empathise with Martha, the clone recognised all that Martha wanted to do with her life and urged her to follow through on it. (TV: The Sontaran Stratagem / The Poison Sky)