Homura’s cold personality developed from having lived through the same timeline over and over again. She was befriended and eventually saved from a witch by Madoka, but Madoka was unfortunately killed in her battle with Walpurgis Night. Homura then decided to make a contract with Kyubey in order to protect Madoka. She became a magical girl with the ability to manipulate time, allowing her to return to her first meeting with Madoka in order to try and change her fate.
I think I may have died from cuteness. Please excuse me for not being able to come up with a witty comment. Thanks to Emily for sharing this!