Choosing and having good companions is extremely important for many reasons and from many aspects.
1) Mankind cannot live alone; every individual must live and interact with others, and when interacting with others, one either influences or is himself influenced.
2) Those people whom you sit with and take as friends are inevitably from one of the two following categories. They will either be good individuals - who guide and encourage you towards what is good and help you in accomplishing that which Allah has ordered, or they are going to be bad - encouraging you to do what is pleasing to Satan and that which misleads you and leads you to the Hell-Fire.
3) When the Prophet was sent with the mission to establish Islam, he did not do it on his own. Rather, Allah chose for him companions who accompanied him and who carried the Message until it was complete.
These three aspects show the importance of having good companions; companions who are righteous. Such companions will help you and enjoin you to do what is good, remind you of Allah, and forbid you from doing what is evil. These aspects also show the importance of avoiding befriending bad companions who will have a bad effect upon you, who will help you in doing deeds which are displeasing to Allah and which lead to Hell-Fire.
The Prophet gave a good similitude regarding this, as he said: "The example of a good companion (who sits with you) in comparison with a bad one is like that of the musk seller and the blacksmith's bellows; from the first you would either buy musk or enjoy its good smell while the bellows would either burn your body or your clothes or you get a bad nasty smell thereof.” [Al-Bukhari and Muslim]
The Prophet explained the matter of good companionship, so that no room is left for doubt or confusion, when he said: "A person is upon the religion of his close friend, so beware whom you befriend." [Abu Daawood and At-Tirmithi]
This means that a person will be upon the same methodology as his friend, the same path as his friend, the same nature, manner and behavior as his friend. So we must be careful about whom we befriend. There is an Arabic saying: 'Your companion is what pulls you to something.' So if your companion is good, he will pull you towards that which is good. He will order you to do what is good and forbid you from doing what is evil. If he observes you committing sins, he would warn you, if he becomes aware of your shortcomings, he would advise you, and if he finds a fault in you, he would conceal it and not disclose it to others. About this, the Prophet said: "…..Whoever conceals (the fault of) a Muslim, Allah will conceal his fault on the day of Judgment." [Abu Daawood]
So should you see a fault in your brother, you should wish to remove that fault from him and not expose it to the people. This is what is required by brotherhood. This stresses the importance of choosing friends who are upon the correct way, who are loyal, and who conceal your faults whilst ordering you to do good and forbid you from doing evil; they will stand beside you, support you, and co-operate with you upon all that is good.
This principle is important from the standpoint of how the religion is to be established, and from the standpoint of what brotherhood is and what it does. Indeed, the reason for taking a companion is so that he helps you establish Islam, and so that you help him worship Allah. We find a good example in the Prophet Moosaa the one whom Allah chose and spoke to. When Allah sent him to Pharaoh, he (Moosaa) said as Allah informs us Saying (what means): {And appoint for me a helper from my family, Haaroon - my brother; increase my strength with him, and let him share my task (of conveying Allah's Message and Prophethood), that we may glorify You much and remember You much.} [Quran 20:29-34]
Moosaa wanted his brother to support and help him, protect him and accompany him. This is exactly what the believers do for one another. What binds the believers together and makes them brothers is the bond of faith. The Prophet said: "There are three characteristics, whoever attains them will taste the sweetness of faith: That Allah and His Messenger are more beloved to him than anyone else, that he loves a person and does not love him except for the sake of Allah, and that he would hate to revert to unbelief just as he would hate to be thrown into the Fire." [Al-Bukhari and Muslim]
Thus, the connection between the believers is based upon faith and sincere brotherhood. Beware against taking any companion if such companionship is based upon other than this; for if you were to do that, you would then bite your hands in grief just as the unjust ones will bite their hands in grief. Allah Says (what means): {And (remember) the Day when the wrong-doer (oppressor, polytheist etc.) will bite at his hand, he will say: ‘Oh! Would that I had taken a path with the Messenger. Ah! Woe to me! Would that I had never taken so-and-so as a friend! He indeed led me astray from the Reminder (the Quran) after it had come to me….’} [Quran 25:27-29]
Allah also Says (what means): {And whosoever turns away from the remembrance of the Most Beneficent (Allah), We appoint for him Satan to be a Qareen (intimate companion) to him.} [Quran 43:36]
So all of the physical togetherness that you see around you, which is based upon other than faith, will be wiped away on that Day, and it will be a source of misery and torture. Allah Says (what means): {Close friends, that Day, will be enemies to each other, except for the righteous.} [Quran 43:67]