It is very possible to be wealthy and be good in the eyes of God. The reason we’re told that it is harder for a rich man to enter Heaven than for a camel to pass through the eye of a needle is because money can easily become a false god. Oftentimes, the more someone has, the more they want; money becomes such a focus, that God becomes less of a focus, sadly. Those who have less or are poor tend to rely on God much, much more than those who have been blessed with abundance. To always be good stewards of what God gives us is very important. God wants us to be happy in our lives. He loves us, and loves seeing us smile; His desire is not for us to all be equally destitute, starving, naked, and homeless. If that were the case, who would help whom? God has given each of us talents and He gives us money, and we should use those blessings to glorify Him. In your example, performing medical work for the poor and needy for free, or for the lawyer to represent - for free - someone in need. We can clothe those who are naked, feed those who go hungry, shelter those whom we’re able, etc.
Put God first and know that any money or talents that you have are His and come to us as blessings from Him. Use them with this as your guide, and a wealthy person can most certainly be good in the eyes of God. Give generously of your abundance, and do it for His glory.