This review has spoilers.
This is one of the best movies I have watched. It has a very deep meaning.
This movie is a representation of spiritual concepts and not a science fiction. So there is not a logic to how the time loop was caused or ended. The loop is used as a metaphor. So let's not understand it with logic but in a metaphorical way to relate it to real life.
Phil was always cribbing about something or the other. He used to get upset at small small things easily. He hated his job, he hated people, he hated nature, he was never excited about anything. He was trapped in his ego. That made him think of himself as superior than others. He also hurt others by being vocal about it. Obviously, no one liked him much. On the contrary, Rita looked at everything joyfully. She was a blissful human being and she was liked by all around her. They both were opposites of each other. They both were going through the similar life situations and circumstances but their attitude to handle the outside circumstances were completely different.
In real life, one has to go through the same lessons/ situations again and again to break himself free out of the suffering caused by ego. Just for example, one will be stuck in an unending cycle of bad relationships until he learns from it and break the loop. In the movie, “the always cribbing Phil” was stuck in such cycle of events that are unpleasing for him. No matter what he did, he couldn't change the events. He was stuck and now he was more miserable than before because of the frustration of not able to control the outside circumstances. He tried everything to come out of the loop- killing himself, manipulating situations to win Rita, some illegal activities and what not. But no use. Finally, he started thinking himself as “a god”. But that too was not true since he didn't have any control over an old man's death. He realised, he is not “a god".
So, how did he break the loop? After living a horrible day again and again, he finally started to understand that instead of cribbing and being miserable he just can enjoy what's happening. He started to help people, he was being honest to Rita, he started living in NOW. He became an amazing human being. All started to like him. Everything changed automatically when he stared living joyfully. With this attitude, he was no mo about breaking the loop. He was fine with whatever happens. He had found his joy. And, the next day, he wakes up to a new day. Finally, the loop was broken.
In Buddhism and Hinduism, this is called Samsara. In Christianity it is called Purgatory.