Recommendation letters are all about trust: why should the person reading the recommendation letter believe the person who is writing it, when they say that they should place trust in you?
Thus, all else being equal, a professor with better qualifications provides a stronger recommendation.
Other considerations, however, can be more important, as it all boils down to the basic question of trust. For example:
- A little-known professor who knows you well and has worked together with you is a better recommender than a world-famous professor who can only say: "This student was one of 100 who got a good grade in my giant class this year."
- A professor with a close colleague in the department where you are applying may be much more trusted in their recommendation than a world-famous professor who nobody in the department knows personally.
Furthermore, you probably will have more than one letter writer, and diversity in your letter-writers can be a virtue: some more prominent, others more in depth, etc. Thus, you really need to look at this as a whole package, and say: "What is the combination of people who will, as a collective, present the most favorable and trustworthy picture of me to the particular places where I am applying?"