Question: According to Islam what is the purpose of a friend? How does one show gratitude to Allah for a friend?
Answer: Wa alaikum assalam wa rahmatullahi wa barakatuh,
I pray that you are in the best of health and faith, insha’Allah.
One’s friends should be people who are helping one draw closer to one’s Lord.
Imam Ghazali (rah) in his Beginning of Guidance (Bidayat al-Hidaya) lists a number of qualities to look for in a friend noting the words of the Prophet (Allah bless him and give him peace), “A person’s religious life is only as good as that of his friend, so let one of you consider well whom he befriends.” [Tirmidhi]
– As there is no good friendship with a foolish person;
– Specifically seek someone with practical intelligence who has the capacity to seek benefit, even if worldly;
 Good Character
– Ghazali states that someone of bad character is one who cannot restrain their [i] anger or [ii] desire;
– Somebody who truly cares for others. “The religion is sincere counsel.”
– “Do not obey someone whose heart We have made heedless of Our remembrance, who follows his inclinations, whose case has gone beyond all bounds.” [Qur’an, 18:28]
– As witnessing the transgression of a wrongdoer on a regular basis will remove from your heart all sense of the enormity of the crimes and make them seem insignificant.
 Lack of Greed
– Someone concerned with amassing “things” of this world
– Human nature is designed to imitate and follow (by example), so one person’s nature may take from another without even realizing it.
– As one will always face deception from the liar.
Imam Ghazali (rah) continues that after finding a decent friend, one should uphold, respect and fulfill the duties of being a friend.
Gratitude and Growing
Allah Most High says in the Qur’an, ‘If you are thankful, I will surely increase you’ [Qur’an, 14:7] The Messenger of Allah (Allah bless him and give him peace) said, ‘Whoever does not thank people has not thanked Allah’. [Tirmidhi]
Be grateful for them, appreciate them, and grow in love for one another — the Messenger of Allah (Allah bless him and give him peace) said, narrating from His Lord, “My love is incumbent for those who love one another for my sake; those who sit with one another for My sake; those who visit each other for My sake; and those who spend on each other for My sake.” [Musnad Ahmad]
And Allah knows best.