The Ramayan is certainly the epic poem and one of the oldest legends in the world. Scholars and Historians claims that it was composed around 500-1500 BC. As per Vedas and devout Hindu believes, Sri Ram lived in the Treta Yuga whic occurred many hundred millennia ago. That was the time assumed when Maharishi Valmiki first told his immortal story. This epic is called the Adi Kavya and Maharishi Valmiki is known as Adi Kavi, whic is the world's first poem. As with other great Hindu Epics, the true purpose of the Ramayan is also to awaken its spiritually, help attaining the supreme consciousness, and to send him forth on the great journey that leads to Moksha, to God.
Before dwelling deeper into the ocean of Ramayan, let us know in more detail about Maharishi Valmiki. The Uttara Kanda of Ramayan itself tells the story of Maharishi Valmiki's earlier life. In his earlier days he was a jungle robber named Ratnakar and kills people to rob them. People were so fearful of him and run for their life seeing him. He had a family to look after and he was doing robbery for living. Once, the robber tried to rob the divine sage Narad for the benefit of his family. Narad asked him if his family would also bear the sin with him if they are surviving on your robbery. Ratnakar positively replied to Narad that he is doing everything to look after the family and they will definitely support me in every good and bad situation. However, Narad asked him to confirm the same from his family. To his surprise, his family rejected the bearing of sins for which they were not responsible. Dejected and feeling deceived, he felt so sad that he has done every thing to make them happy and when the bad situaiton came, they were the first to revert back. He finally understood the truth of life and asked Narad for forgiveness. Narad taught the robber the mantra for salvation (Moksha). But, the mantra in question, the name of Sri Ram, was not to be given to murderers, robbers and the like people. Narad thus told him to chant "Mara Mara" continuously which is the phonetic anagram of "Ram". This was he can coninuously recite Ram and it will not be an offense too. The robber started chanting Ram and meditated for many years. He was so much involved into the meditation that ant-hills grew around his body and started covering him. Seeing his dedication, finally a divine voice declared his penance successful and bestowed him with the name "Valmiki" - "one born out of ant hills".