Lucas didn't really talk about it, so the answers you seek can be found in the novel, "Tatooine Ghost". It's revealed that Cliegg had come to Mos Espa to do business and met Shmi when he visited Watto's shop. He kept coming back over a period of time and they started to fall in love. He had to buy her in order to secure her freedom, since Watto wasn't going to get the shaft again. Once that was done, Cliegg formally freed her of being a slave and they got married. The money that Watto had received wound up being lost to his growing gambling debt.