Mr. Smith was originally a cystal like alien called a Xylok, who was stored in a super computer. In the distant past a Xylok ship had crashed into the Earth, trapping the Xyloks in the crust of the planet. It is believed that that earth shock wiped out the dinosaurs, but it may be speculated that it was the Xyloks that did. When the volcano Krakatoa erupted, one crystal escaped. Centuries later, Sarah Jane Smith retrieved the living crystal, took it to her home on 13 Bannerman Road, and found it could communicate with her via her laptop. The crystal informed her how to build the computer to house the living crystal. Sarah Jane did not know at this time about the Xyloks or that Mr. Smith planned to free the other Xyloks, even at the cost of the planet itself.
At first it appeared that Mr. Smith was a loyal friend to Sarah Jane but it was soon revealed that he helped members of the Slitheen family on Earth to make a fake photo of Luke the adopted son of Sarah Jane making it seem that she kidnapped him from his "real" parents who were actually slitheen in disguise. Mr. Smith then reveals his evil plans and tries to stop Luke's friend Clyde almost killing him.
When the slitheen were stopped, Sarah Jane's loyal robotic dog companion called K-9 a gift from the Doctor arrived to help stop Mr. Smith. K-9 and Mr. Smith had a brief laser battle but K-9 and Sarah Jane managed to reboot Mr. Smith into thinking that it was his job to save the world.
Ever since Mr. Smith's reboot he has became an important ally and friend to Sarah Jane, despite some anger towards K-9. Mr. Smith would help Sarah Jane through some of her most toughest challenges, even helping her locate the Doctor during the Dalek invasion.