Let it be known that the Ramayana occured 4 Yuga cycles before this, whilst Mahabharata occured in the 28th Dwapara Yuga.
In the twenty-eighth aeon of Dwapara, there will be Dwaipayana Vyasa, the son of Parashara, and the most excellent of Purushas [Vishnu] shall be born as Krishna with his one-sixth part, as the foremost of the sons of Vasudeva. (Shatrudra Samhita, Shiva Purana.)
How Ramayana became known to Valmiki
1.) In the first Sarga of the Bala Kanda (First Book of Youth) in Ramayana, it describes:
Narada Muni, the master of sages, and the divine seer from Heaven, gives Valmiki a brief talk about who Rama was.
tapaH svaadhyaaya nirataam tapasvii vaagvidaam varam |
naaradam paripapracCha vaalmiikiH muni pu.mgavam || 1-1-1
A thoughtful-meditator, an eternally studious sage in scriptures about the Truth and Untruth, a sagacious thinker, and a sublime enunciator among all expert enunciators is Narada, and with such a Divine Sage Narada, the Sage-Poet Valmiki is inquisitively enquiring about a man who is a composite for all merited endowments in his form and calibre. [1-1-1]
The Sage-Poet Valmiki is inquisitively enquiring about a man who is a composite for all merited endowments in his form and calibre: "Who really is that person in this present world, who is principled and also a potential one, a conscientious one, a redeemer, and also a truth-teller and self-determined in his deed? Who is he conduct-wise blent with good-conduct. Who in respect of all beings is benign? Who is adept and also the ablest one [and] also uniquely good to look to? Who is that courageous one, who controlled his ire, who is brilliant, non-jealous and even whom do the gods fear, when provoked to war?"
Thus, Narada started briefly retelling who Rama was:
ikSvaaku va.msha prabhavo raamo naama janaiH shrutaH |
niyata aatmaa mahaaviiryo dyutimaan dhR^itimaan vashii || 1-1-8
"One emerged from Ikshvaku dynasty and known to people as Rama by his name, and he is conscientious, highly valorous, resplendent, steadfast and a controller of vice and vile... and his own senses, as well... [1-1-8]
raamasya dayitaa bhaaryaa nityam praaNa samaa hitaa || 1-1-26
janakasya kule jaataa deva maayeva nir.hmitaa |
sarva lakSaNa sa.mpannaa naariiNaam uttamaa vadhuuH || 1-1-27
siitaapya anugataa raamam shashinam rohiNii yathaa |
"Seetha, the best one among ladies, a possessor of all best qualities befitting to an ideal lady, the one who is as though fashioned by a Divine marvel, born in Janaka's family and became Dasharatha's daughter-in-law, and she who is the loving wife and an ever-amiable alter ego of Rama, even she followed Rama to forests, as with Lady Rohini following the Moon... [1-1-26b, 27, 28a]
This entire narration of Rama can be found here.
Afterwards, Valmiki goes to a river to bathe himself and finds a hunter killing a bird. This enrages Valmiki, who curses the man. The curse is actually a verse from the Ramayana that he had never heard before, and this wasn't what Valmiki intended to say. It's rich in grammar. The full description can be found in the small introductory before the Sarga.
Sage Valmiki goes to River Tamasa for a bath and sees a couple of birds, of which a hunter kills one. Valmiki unintentionally utters a poem, which is rich in grammar and new in metre, of which he is very much confused as to why such a poem has come from his tongue. Brahma, the presiding deity of letters appears and ordains Valmiki to author Ramayana, excellent epic of Rama, for which purpose alone he gave such divine meter and grammar to him.
Here is the sentence he uttered:
tathaa vidhim dvijam dR^ishhTvaa nishhaadena nipaatitam |
R^isheH dharmaatmaanaH tasya kaaruNyam samapadyata || 1-2-13
On seeing at that bird felled that way by the tribal hunter, compassion is aroused in that kind-hearted sage Valmiki. [1-2-13]
tataH karuNa veditvaat adharmo ayam iti dvijaH |
nishaamya rudatiim krounchiim idam vacanam abraiit || 1-2-14
Then on seeing the wailing female krounchi bird, compassion haunting him and apperceiving the killing of male bird as unjust, the sage uttered this sentence... [1-2-14]
maa nishhaada pratiSThaamtva | magamaH shaashvatiiH samaaH |
yat krau~Ncha mithunaat eka | mavadhiiH kaama mohitam || 1-2-15
"Oh! Ill-fated Hunter, by which reason you have killed one male bird of the couple, when it is in its lustful passion, thereby you will get an ever-lasting reputation for ages to come..." [1-2-15]
Valmiki then ponderd about the sentence he just said:
tasya evam bruvataH chintaa babhuuva hR^idi viikshataH |
shokaartena asya shakuneH kim idam vyaahR^itam mayaa || 1-2-16
On saying thus, and pondering for a while in his heart, 'annoyed by the anguish for that bird, what is it uttered by me...' thus he became cogitative of those lines uttered. [1-2-16]
Brahma goes to visit Valmiki and gives him the boon of remembering Rama's full story. He directs Valmiki to write it down.
aajagaama tataH brahmo lokakartaa svayam prabhuH |
chatur mukho mahaatejaa draSTum tam munipuN^gavam || 1-2-23
Then, the great resplendent Four-faced creator of fourteen worlds, almighty Brahma, arrived there on his own, to see that eminent saint Valmiki. [1-2-23]
tam uvaacha tato brahmaa prahasan munipu.ngavam | 1-2-30
shloka evaastvayaam baddho na atra kaaryaa vichaaraNaa ||
Then, Brahma smilingly spoke to that eminent saint Valmiki, "But, what that is composed is a verse only... and there is no need to think through... [1-2-30b-31a]
mat cChandaat eva te brahman pravR^itte ayam sarasvatii | 1-2-31
raamasya charitam kR^itsnam kuru tvam R^ishhisattama |
"Oh, Brahman, that speech of yours sprang forth at my wish alone, hence oh, eminent sage, you shall render the legend of Rama, in its entirety... [1-2-31b-32a]
dharmaatmano bhagavato loke raamasya dhiimataH || 1-2-32
vR^ittam kathaya dhiirasya yathaa te naaradaat shrutam |
"You shall narrate the legend of Rama, the virtuous, intellectual and an intrepid one, and a godlike person in this world as well, as you have heard it from sage Narada. [1-2-32b-33a]
rahasyam cha prakaasham cha yad vR^ittam tasya dhiimataH || 1-2-33
raamasya saha saumitre raakshasaanaam cha sarvashaH |
vaidehyaaH cha eva yad vR^ittam prakaasham yadi vaa rahaH || 1-2-34
tat ca api aviditam sarvam viditam te bhaviSyati |
"The adventures of valorous Rama along with Lakshmana, and the misadventures of demons, known or unknown in every detail, and even the plight of Vaidehi which is either revealed or un-revealed so far, and whatever legend that has happened, all that will also be known to you, even if it were to be unknown, as yet... [1-2-33b-35a]
The descendent of Rama fighting in Mahabharata
Yes, it is true that a descendent of Rama did fight in Mahabharata, and did die. However, make no mistake, this man was not divine. He was simply a descendent of Rama's dynasty; the Ikshvaku, and since Rama was born to a normal kingdom called Ayodhya, he wasn't born special or anything.
His name was Brihadbala, and he was an unrighteous king who fought for the Kauravas. He was the son of Takshaka, grandson of Prasenajita, and great-grandson of Vishvahsa. He was the 117th generation of the Ikshvaku, and the very last of his lineage; and was killed by Abhimanyu during the Kurukshetra War. His brief story can be found in the Bhagvata Purana, book 9, Chapter 12.
- Viśvasāhva’s son was Prasenajit whose son was Takṣaka; his son was Bṛhadbala who was killed in the battle by your father (Abhimanyu).
Another such reference can be found in the Brahmanda Purana, Book 3, Chapter 74. His details of his death isn't mentioned.
104-106. These are said to be the descendants of Ikṣvāku. They will be born in the Kaliyuga in the family of Bṛhadbala.
They shall be endowed with great vigour and exploit. They will be heroic, learned and truthful. They will conquer the sense-organs.
Yet another reference can be found Vishnu Purana, Book 4, Chapter IV:
his son was Viśrutavat; and his son was Vrihadbala, who was killed in the great war by Abhimanyu, the son of Añjuna. These are the most distinguished princes in the family of Ikṣvāku: whoever listens to the account of them will be purified from all his sins.
I hope this cleared up any confusion or satiated any of your queries.