Hanuman had sat on the flag of Arjuna's chariot during the Kurukshetra war. But, what was it for?
There was not even a single instance in which Hanuman played any role.
Hanuman played a very minor role in the Kurukshetra war because Bhima softly declines Hanuman's offer for help.
O descendant of Bharata, with fraternal feeling ask from me a boon. If you desire that I shall go to Hastinapur and kill the insignificant sons of Dhritarashtra, I shall even do this (for your sake) or that I shall grind that city with Stone.
Or that I shall bind Duryodhana and bring him here. O greatly powerful hero, even this I shall do today.
Having heard the words of that high-souled one, Bhimasena with a delighted heart thus spoke to Hanuman.
“O foremost of monkeys, O mighty-armed hero, I consider all this already performed by you. Good come to you. I ask you to be pleased with me.
O mighty-armed hero, when you have become our protector, the Pandavas have (already) secured their lord. With your effulgence we shall conquer all our enemies.”
Having been thus addressed, Hanuman then spoke to Bhimasena, “From fraternal affection and friendship, I shall do you good.”
By rushing into the enemy’s force armed with numerous arrows and javelins when you shall give forth lion-like roars, O hero, O greatly powerful one,
I shall then with my own (shouts) add to your shouts. Remaining on Vijaya's (Arjuna) flag-staff, I shall send forth fearful shouts. Which will damp the courage of your enemies. You will then be able to destroy them with ease.”
Having thus spoken to the son of Pandu, Hanuman first pointed out to him the way and disappeared.
We are all familiar with His extremely important role in Ramayana. But only a few of us know that Lord Hanuman also appears in the epic Mahabharata, twice. It is a well-known fact that Lord Hanuman is one of the 'Chiranjeevis'. Chiranjeevis are the people who are supposed to be immortals. Hanuman, being one of the Chiranjeevis has been granted with the boon to live forever.
So, we find Lord Hanuman being mentioned in Mahabharata. Lord Hanuman is also considered the brother of Bhima as they have the same father, Vayu. Therefore the first mention of Lord Hanuman in Mahabharata comes when He meets Bhima during the Pandavas exile and the second time when Lord Hanuman protected the chariot of Arjuna throughout the battle of Kurukshetra by residing in Arjuna's flag read more here