I am presently reflecting on Romans 5, hence why I found this page. This is my Work In Progress thought - I hope it helps, and I certainly welcome feedback.
Romans 5:6-8 (NASB)
6 For while we were still helpless, at the right time Christ died for the ungodly. 7 For one will hardly die for a righteous man; though perhaps for the good man someone would dare even to die. 8 But God demonstrates His own love toward us, in that while we were yet sinners, Christ died for us.
Certainly "righteous" and "good" are contrasted with "sinners" in v8. However, I don't think this answers the question. To understand the significance of these two words, we look back to v6, where we (the ungodly/sinners) are also described as helpless.
As sinners, we are unable to gain eternal relationship with God ourselves. Hence God provides peace through Jesus (v1), fills our hearts with his love (v5), gives us the Holy Spirit (v5) and ultimately saves us from judgement (vv9-10).
In contrast to helpless me, the "righteous" person needs no help entering God's eternal relationship - that's what righteous means! This is consistent with the rest of Romans, and the rest of scripture - if a person actually is righteous, as Jesus was, then nobody needs to die for them.
Also in contrast to helpless me, the "good" person projects attributes of godliness throughout their life. Though they may not be righteous in the sense of meeting God's requirements for eternal relationship, some people may feel the urge to die for that good person, that they might be glorified with God.
I still feel shaky on the "good" - which is not surprising perhaps, given Jesus himself deferred that designation to God alone (Mark 10:18). There's more to it yet. Nonetheless, I do think "righteous" and "good" in Romans 5:7 are better understood against "helpless", as this explains Paul's comments on numbers of people willing to die for them.
Current teaching does assert that "good" is better than "righteous" - just as any of us might prefer. Sermons, etc compare the stuffy, cold, unloving righteous people with the warm, caring, loving good people we know. Not really helpful. Paul does not appear to be discerning between them based on how likeable or humanitarian they are. We need to resolve Paul's use of the terms, and work with those, not with popular projections of how those terms make us feel.
I hope this helps.
New American Standard Bible (NASB) Copyright © 1960, 1962, 1963, 1968,
1971, 1972, 1973, 1975, 1977, 1995 by The Lockman Foundation