The salaf used to say that the soul is a thief. It takes the characteristics of those whom it accompanies. If it accompanies evil people, it will become evil, and if it accompanies the righteous, then it will become righteous.
Just as Allāh commanded the Prophet (ṣallallāhu alayhi wa-sallam) to keep companionship with the pious and righteous regardless of their wealth or status so too we are encouraged to keep companionship with the pious, regardless of their wealth or status. Allāh is only concerned with one’s ibādah; He is not concerned with one’s wealth, status or looks. Allāh only looks to one’s deeds.
We are encouraged to keep with the people who makeʿibādah much, even if they are poor. Don’t be fooled by the pump and glitter of this world. The people of the dunyā don’t remind us of the ākhirah; they only make us remember useless things that are devoid of the remembrance of Allāh. They inevitably lead us to the hellfire.
When we leave the companionship of the righteous for the companionship of the people who only desire the dunyā, they will make our hearts become attached to the dunyā. Conversely, if we accompany the righteous, they will remind us of Allāh. They will remind us of the dhikr of Allāh and will keep our hearts focused on the ākirah. They will not tolerate us openly sinning in front of them. These people will lead us to the Jannah.
So it is upon us to choose our companions wisely as they can pave the path to our Jannah or our Jahannum.