Mahabharata today has 100,000 slokas and is believed to be written by Sage Veda Vyasa, but in reality it was narrated by him and written by Lord Ganesha.
When first narrated, it had only 8,800 slokas and Mahabharata original name was ‘Jaya‘ (Jayam) as written by Ganesha.
Then Vyasa’s disciple Vaisampayana narrated this story to King Janamejaya (Pariskshit’s son and Abhimanyu’s grandson) along with additional and elaborated stories, during Sarpa Yaagam (A Yagna that is performed to bring snakes to extinction by letting them burn in flames as a revenge against Takshaka, a snake who killed King Parikshit)
This made it expand to 24,000 slokas and was named ‘Vijaya (Vijayam)‘ and then renamed it as ‘Bharata‘.
In next generation, Ugrasravas, belonged to the Suta caste, who were typically the bards of Puranic literature, narrated this story to sageSaunaka and other sages in Naimisa forest.
Ugrasravas (also named as Suta muni or Suta Goswami) was the son of sage Lomaharshana and belong to disciple chain to Vyasa.
The full 100,000 verses of the Mahabharata was completed several centuries later by addition of many stories and was finally named as ‘Mahabharata‘.
Bhagavad Gita is one such addition into Mahabharata, which was done during later generations and written according to the conditions of the society that prevailed during those times.
It is placed in Mahabharata’s Bhishma Parva with 700 slokas divided between 18 chapters.
In the epic Mahabharata, Sanjaya, counsellor of the Kuru king Dhritarashtra, after returning from the battlefield to announce the death of Bhisma begins recounting the details of the Mahabharata war. Bhagavad Gita forms the content of this recollection.
Gita begins before the start of the climactic Kurukshetra war, where the Pandava prince Arjuna is filled with doubt on the battlefield. Realizing that his enemies are his own relatives, beloved friends, and revered teachers, he turns to his charioteer and guide, Krishna, for advice. Responding to Arjuna’s confusion and moral dilemma, Krishna explains to Arjuna his duties as a warrior and prince, elaborating on a variety of philosophical concepts.
Why would Krishna liesurely narrate 700 slokas in 18 chapters to Arjuna, when war was just about to begin.
It would take him entire day to recite that much of concept and also showing his Viswaroopam (Infinitude) in the end.
Would Kaurava army wait for all these preachings to be completed and then start the war ?
What would both armies be doing when these two were immersed in their own discussions ?
Krishna must have simply asked Arjuna to do his duty and leave the result to him and to convince him, he must have shown hisViswaroopam for a minute. This will make Arjuna believe that Krishna is god and has already decided the outcome of this war, for which he is a mere pawn.
It is clearly evident that Gita was written by multiple persons as few intial slokas appear in first person narrative and suddenly it jumps into third person narrtive.
Gajanan Shripat Khair, who researched for 43 years on Bhagavad Gita, concluded in his book ‘Quest for the original Gita‘ that infact it was written by 3 persons over 400 years and that is why narrative lacks continuity.
Also few inclusions like ‘description/creation of caste system’ , ‘women, sinners and lower castes’ being treated similarly etc were according to the society in those years.
In later generations, spiritual gurus have included it in PRASTHANA TRAYAM along with Upanishadas and Bramsutra
Similarly, Vishnu Sahasranamam is narrated through Bhishma’s character before his death.
This Vishnu sahasranama is found in the Santi Parva of the Mahabharata is the most popular version of the 1,000 names of Vishnu. Another version exists in the Padma Purana and Matsya Purana. Each name eulogizes one of His countless great attributes.
This also must have been included into Mahabharata from those puranas.
Infact, both Bhagavad Gita and Vishnu Sahasranamam became popular after Adi Sankaracharya wrote commentaries on them in 8th century AD.
The Mahabharata probably reached its final form by the early Gupta period (c. 4th century) when kings ordered complete rewriting of all puranas to preserve them for future generations.
Unlike the Vedas, which have to be preserved letter-perfect, the epic was a popular work whose reciters would inevitably conform to changes in language and style.
So, many additions were made to it by writers of that generation.
Mention of the Huna in the Bhishma-parva however appears to imply that this parva may have been edited around the 4th century
The narration (Bharata) of the history of Bharata kings by sage Vaisampayana to Kuru king Janamejaya was embedded within this narration of Ugrasrava Sauti. Vaisampayana’s narration (Jaya) in turn contains the narration of Kurukshetra War by Sanjaya, to Kuru king Dhritarashtra. Thus Mahābhārata has as a Story within a story structure.