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.
Sukumari Bhattacharji, ‘A revaluation of Valmiki's "Rama"’ Social Scientist 30(1-2), 2002:31-49; Luis Gonzalez-Reimann, ‘The divinity of Rama in the Ramayana of Valmiki’ Journal of Indian Philosophy 34(3), 2006:203-220; K.K.Handique, et al., ‘Part 1: The Two Great Epics’ in The Cultural Heritage of India. Volume II (Calcutta: The Ramakrishna Mission, rev. 2nd ed., 1962), chapters 1-8; Ramdas Lamb, 'Ram' in Brill’s encyclopedia of Hinduism. Vol.III, edited by Knut A.Jacobsen (Leiden: Brill, 2011):112-118; A.K.Ramanujan, ‘Three hundred Ramayanas’  in Many Ramayanas: the diversity of a narrative tradition in South Asia, edited by Paula Richman (Berkeley: University of California Press, 1991):22-49 https://300ramayanas.wikispaces.com/ ; Paula Richman, ‘The diversity of the Ramayana tradition’ in Many Ramayanas: the diversity of a narrative tradition in South Asia, edited by Paula Richman (Berkeley: University of California Press, 1991):3-21; Dinesh Sakalani, ‘Questioning the questioning of Ramayanas’ Annals of the Bhandarkar Oriental Research Institute v85, 2004:51-65; Geoffrey Samuel, The origins of yoga and tantra: Indic religions to the thirteenth century (Cambridge: Cambridge University Press, 2008