"Rama" is called Taraka Mantra. Taraka Mantra is one which helps a person to cross over the cycle of birth and death to immortalhood, i.e., it helps one merge with the Almighty. It is a mantra which helps you rid of your bad and good karmas. [Even good karmas are to be got rid off because one is born to enjoy the fruits of good karma. For example look at the irony of this guy who has been elected five times as Chief Minister in spite of his present evil karma of being an anti-Hindu, a brahmin hater, a temple hater and cow hater. But he will definitely enjoy its "fruits" as well may be as a dweller on the banks of Kooum as compared to his present heaven of air-conditioned comfort etc. Sorry I have digressed..coming back to Sri Rama Nama]
So this taraka mantra "Rama" is derived from the roots of two maha mantras -- Om Namo Narayanaya and Om Nama: Shivaya -- "Ra" from Namo Narayanaya and "Ma" from Nama Shivaya.
Although my preferred japam is the Gayatri but before gaining sleep I always chant "Rama Rama Rama Rama...." after remembering my Guru who initiated me into this japa and Sri Maha Ganapati; even before I hit 100 I dose off to a state of dreamless pleasant sleep.
"Rama" namam is the one mantra which is chanted into the ears of those who are at the verge of shedding this mortal coil. But whether they are in a state of hearing that or not is a moot question. In all likelihood they are already in the clutches of "Chitra-gupta -- which means secret picture" where they are shown as if flowing from a projector, the movie of their life from childhood to that stage when they are in the last stages of their life here; they are shown their likes and dislikes, the pleasures and pains they endured, the people who gave or caused them this pleasure/pain etc. Depending upon the "scene" in this very private movie the expression on their face change -- sometimes smiling, sometimes staring, sometimes shrinking in horror etc. Watching this the relatives who crowd around the person who is in his death throes imagine that they are reacting to the presence of some near or dear one and all that.
This is also one of the reasons that we are discouraged from having dogs and cats as pet animals. Dogs in particular are capable of providing us so much of happiness by their loyalty and devotion that in all probability we would be remembering the dog in our last moments. The Gita says that the person at the verge of death is shown a picture of his next birth. Definitely you would not like to remember your dog in that stage which would result in your attaining a dog's birth.
So if you are in the habit of chanting any particular mantra on a regular basis, you will notice that even without your volunteering it, the mantra goes on repeating itself at the back of your mind all the time -- even when you are asleep. That is called "ajapa japam". It goes on and on even when you are engaged in conversing with somebody, when you are engaged in your daily routine.
Therefore a person who is all the while busy chanting the Gayatri or the taraka mantra of Rama namam or the Panchaakshari, Ashtaakshari, Sastaakshari, Sathakshari, that particular mantra will take over controls of the dying person's thought process and he will die remembering the Almighty's name. Do I have to say to what world he/she will go?