We should choose the friend that believes in and abide by our religion (Islam) and gives great respect to what Allah (SWT) and Prophet Muhammad (saw) had ordered us. And we should stay away from the one who is not well mannered and gives no attention to what Islam is about or what pleases or displeases Allah (SWT), for he will surely affect us negatively. There is no good if the companion drowns us in sins and displeasing Allah (SWT). The bases for the actions of those who follow the evil ways are corrupt; their actions are built upon misguidance and deviation.
Good friends are those who share with their companions both happiness and sadness. If we share our feelings with the wrongdoers whose actions are worthless and based on corruption, then we are following the same ways and standards as they are doing, and we will end up being as corrupt as they are, and then we are in a big trouble, how can we face Allah's (SWT) dissatisfaction and displeasure? Instead of making friends with the misguided ones we should befriend the righteous, yet treat the rest in a gracious and just manner. Staying at sufficient distance is necessary; yet treating everybody in a noble and kind manner is required.The danger of having corrupt friends isn't confined to the worldly life. Such friendships produce repentance on the Day of Resurrection, too!
Allah (SWT), the Exalted says in the Noble Qur'an: "And (remember) the day when the unjust one shall bite his hands saying: O! Would that I had taken a way with the Messenger! O woe is me! Would that I had not taken such a one for a friend! Certainly he led me astray from the reminder after it had come to me;" (Surah Al-Furqan, 25:27-29)
The two main regrets on the day of judgement are (1) Not following Prophet Muhammad (saw) on the path of guidance and (2) Befriending a person who diverted one from the truth.
Ali ibn Abi Talib (as) has said: "The felicity of this and the next world lie in two things: firstly, keeping secrets; and secondly, friendship with the good. And the miseries of this and the next world are summed up in two things: firstly, divulging secrets; and secondly, friendship with wicked persons."
So take heed before the inevitable day of judgement comes and we are reckoned for our acts.
Allah (SWT), the Exalted says in the Noble Qur'an: "Friends on that Day will be enemies one to another, except al-Muttaqun (i.e. those who have Taqwa/Piety)." (Surah Az-Zukhruf, 43:67)
It is wise to choose moderation in dealing with friends. Excessive love and confidence in friends are unacceptable since it happens that a friend may change into an enemy and use the secrets that he had shown as weapons.
Allah (SWT), the Exalted says in the Noble Qur'an: "And cooperate in righteousness and piety, but do not cooperate in sin and aggression." (Surah Al-Maeda, 5:2)
There are three types of 'friends'...
Those that are necessary like nourishment and you cannot live without them; those that are like medicine and are beneficial, so you need them sometimes; and finally, those that are like a sickness and you do not need them at all!
Prophet Muhammad (saw) has said, "The believer is like a mirror to other believers (in truthfulness)." Like a mirror, your friend gives you an honest image. He forgives your mistakes, but does not hide or exaggerate your strengths and weaknesses.
Once Prophet Muhammad (saw) was asked, "What person can be the best friend?" "He who helps you remember Allah (SWT), and reminds you when you forget Him," the Prophet Muhammad (saw), counseled.
Ali ibn Abi Talib (as) said: "A friend cannot be considered a friend unless he is tested on three occasions: in time of need, behind your back and after your death."
Indeed if we establish these as the standards of friendship, the believers shall soon find themselves enveloped with friends who will take them closer to Paradise and farther away from the fire of hell.
Allah (SWT) says in the Noble Qur'an: O you who believe! Take care of your souls; he who errs cannot hurt you when you are on the right way; to Allah is your return, of all (of you), so He will inform you of what you did. (Surah Al-Maeda, 5:105)
There are certain tips to remember if you wish to keep a stable friendship.
Do not dispute with him and do not be hostile to him.
Do not ridicule him. Do not quarrel with him. Instead accord friends the respect they deserve.
Do not hold him in contempt nor consider him to be lower than you. Instead guard the honor of your friends during their absence and after their death.
Do not claim precedence and supremacy over him. Instead forgive the short-comings of your friends, because everyone makes mistakes in life.
Do not crack indecent jokes with him.
Finally, we ask Allah (SWT) to make us of the righteous ones and give us companions that will take us away from His Wrath and lead us to His Pleasure and Paradise.