The blind King Dhritarashtra asks Sanjaya to recount to him what happened when his family the Kauravas gathered to fight the Pandavas for control of Hastinapura. His family isn't the rightful heir to the kingdom, but they have assumed control, and Dhritarashtra is trying to preserve it for his son Duryodhana. Sanjaya tells of Arjuna, who has come as leader of the Pandavas to take back his kingdom, with Sri Krishna as his charioteer. The Gita is the conversation between Krishna and Arjuna leading up to the battle.
Arjuna doesn't want to fight. He doesn't understand why he has to shed his family's blood for a kingdom that he doesn't even necessarily want. In his eyes, killing his evil and killing his family is the greatest sin of all. He casts down his weapons and tells Krishna he will not fight. Krishna, then, begins the systematic process of explaining why it is Arjuna's dharmic duty to fight and how he must fight in order to restore his karma.
Krishna first explains the samsaric cycle of birth and death. He says there is no true death of the soul -- simply a sloughing of the body at the end of each round of birth and death. The purpose of this cycle is to allow a person to work off their karma, accumulated through lifetimes of action. If a person completes action selflessly, in service to God, then they can work off their karma, eventually leading to a dissolution of the soul, the achievement of enlightenment and vijnana, and an end to the samsaric cycle. If they act selfishly, then they keep accumulating debt, putting them further and further into karmic debt.