I misread the question when responding at first. The comment clarifies that the OP feels both the chainring and cassette are worn.
Yes, the R7000 or even the R8000 cassette can be used without issue (the R9100 can also be used, but the titanium cogs wear very fast).
The chainrings should be changed if they are worn. Generally, if the chain is too worn, it will wear out the cassette and chainrings. If you let your chain stretch too far, you'll likely need to swap the cassette. The chainrings will wear more slowly, since they have more teeth. Since your groupset is about 8 years old, it's possible you may need new chainrings as well.
From searching, the FC-RS500 uses 5-bolt, 110mm chainrings. Cheaper aftermarket chainrings should be easy to find, if you can't find the original Shimano rings. You don't need to change the whole crankset. The R7000 and similar generation cranksets use 4-bolt chainrings, and at MSRP, the chainrings are pretty close to the cost of a new crankset. They do shift well, but I don't think many people will find it necessary to upgrade to the R7000 crankset from an RS500 or similar. You will have to judge the cost-benefit for yourself.
Preserved initial response for posterity:
You can indeed swap in a new R7000 rear derailleur, or even the Ultegra or Dura Ace version. You don't need to change the FD at the same time. If you did, the new FD would work with the old crankset (the RS500).
That said, are the derailleurs themselves actually worn out? It is possible to wear out derailleurs, but it takes quite a while. The group you reference is probably about 8 years old, but it's still possible to have good shifting on derailleurs this old. If you haven't changed the cables, then that would explain poor shifting and now would be a very good time to re-cable the bike - actually, serious cyclists might change them annually. By now, the pulley wheels could be worn out. These can be replaced easily. There's likely to be dirt built up in the pulley cage, and that can be cleaned out. It's possible the derailleur's pivot points are worn out, and if so, that would warrant a replacement.
Park Tools has a general guide on overhauling rear derailleurs. It might be helpful. I'm not sure that all the steps apply to the 5800 RD.