When Lord Rama is about to be crowned, the devas get agitated. They are afraid that this would mean many years of Rama's rule, without the purpose of the avatara being fulfilled, namely the killing of Ravana. So they go to Brahma and ask him to do something.
Brahma asks Saraswathi to make Kaikeyi say words that will result in the coronation being stopped. Saraswathi refuses, saying that she does not want to make someone say words that will result in undesirable consequences. But the devas tell her that if the coronation is stopped, and Rama goes to the forest, Ravana will get killed eventually. So Kaikeyi's words will only result in good. So Saraswathi agrees to influence Kaikeyi's words. But to disturb Kaikeyi is the first task. That is accomplished by Mantara.
Everyone in Ayodhya loves Rama, but Mantara dislikes Him. Valmiki is unable to explain this hatred, and refers to Mantara as the one born somewhere else, thereby showing that maybe her birth in another kingdom had blinded her to Rama's loveable traits. Mantara, on hearing the commotion outside the palace, climbs the stairs, and sees Kausalya distributing gifts to the people of Ayodhya ahead of the scheduled coronation of Rama. Consumed by jealousy, she hastens to see Kaikeyi.
Valmiki says that Mantara walking towards Kaikeyi's rooms looks like the embodiment of Ravana's sins. It appears as if Ravana's sins have taken the form of Mantara, and are walking to Kaikeyi's chambers, to initiate the process of Ravana's destruction, said M.V. Anantapadmanabhachariar in a discourse.
Mantara is is instrumental in the eventual destruction of Ravana. Had Mantara not poisoned Kaikeyi's mind, the latter would never have thought of crowning Bharata, nor suspected Rama's affection for her.
In this case, God's plans worked through Mantara's scheming. The aim of the Rama avatara was the destruction of Ravana, and this was accomplished through Rama's banishment to the forest. But to bring this about, Kaikeyi raged against Dasaratha, and the one who made her behave so, to accomplish the exile of Rama, was Mantara.