Rama (date uncertain) was a legendary north Indian king whose story is told in the many versions of the Ramayana and also in the Mahabharata. It is obvious that both these texts are multi-layered in the sense that earlier myths of indeterminate age have been incorporated into the core texts as they developed into the texts we know today, reaching the developed text c.200-100BCE.
Traditionally the Ramayana is regarded as having been compiled by Valmiki. Another, much later, rendering of the Ram story is the Ramcaritmanas written in Hindi by Tulsidas.
Modern historians regard these classic Indian texts as chronicles of the wars fought, essentially over resources, between city-states on the fertile Gangetic plain of northern India in the first millennium BCE, especially in the period 700-100BCE. In this context Rama is portrayed as the king of Ayodhya who marries Sita, the adopted daughter of King Janaka of Mithila or Videha sometime in the period 700-500BCE.
Traditional scholars assign considerably earlier dating to the Ramayana and much of the Mahabharata, and regard King Rama as having lived as early as five thousand years ago, or c.3000BCE.
There are many versions of the Ramayana. The late A.K.Ramanujan counted 300+ in 1987; and there have been more since, notably the idiosyncratic cartoon film, Sita's Blues.