The eldest of the Pandava, Yudhisthira, lost his kingdom in a game of dice played against the Kauravas chief, Duriyodhana. Kingdom apart, he staked his brothers and the wife, Draupathi, who was the wife of all five of the Pandava, in the game. Having lost everything, he was allowed to take back his brothers and wife, but, in return, was asked to go on exile for 13 years and remain in anonymity for another year after the completion of the 13 years.
The Pandava completed the term in exile and returned to seek their land, which was denied by the Kauravas. The battle at Kurukshetra began and, with the help of Lord Krishna, the Pandava emerged the winners, killing every one of the Kauravas brothers.
The Bhagavad Gita was told by Krishna to Arjuna on this battlefield. When Arjuna was unwilling to fight his cousins, Krishna conveys the philosophy of Bhagavad Gita, which includes detachment, duty, maya, knowledge, body and mind. The importance of performing one's duty without compromise is highlighted in the Bhagavad Gita.