My brothers, as believers in our glorious Lord Jesus Christ, don't show favoritism.
By definition a friend is someone for whom you have a special affection. A relationship that is more open and preferential than others. James isn’t saying students of Jesus cannot have friends.
Even Jesus had special friends like this. Mary, Martha, Lazarus, Peter, James and especially John!
But having favorites is the natural result of getting to know them and therefore having admiration and affection for who they are.
Favoritism, on the other hand, stems from malignant prejudice against a person before we even get to know anything about who they really are.
We quickly judge them and accept or reject them based on their appearance, education or status - have you not discriminated among yourselves and become judges with evil thoughts?
What James seeks to curb is this human tendency that instinctively works in our hearts to pre-judge people based on externals. Then automatically open our hearts to some and close them to others.
James uses the example of showing favoritism to a rich person and disrespecting a poor person. Perhaps this prejudice is pervasive because of our selfishness and insecurity. After all, a rich person may benefit us economically while a poor person cannot and may in fact have the opposite effect.
Students of Jesus follow the Teacher who had favorites but did not show favoritism. He did not seek to curry the favors of the rich, the religious intelligentsia or the political power brokers.
Jesus taught and healed and cared for the poor and the rich alike. He associated with the uneducated masses and was at home in the meanest place and He died for all and anyone can become His student!