My plan was to keep the Black rook on the 5th or 4th rank to cutoff
the White king and advance the h and g pawns. But then what?
Your plan is a bad one.
The general rule in rook and pawn endgames is:
- Your king protects your pawns
- Your rook attacks your opponent's pawns
You can add another one:
As you can see your passed pawns are not your g and h pawns. Therefore you should not be pushing those pawns as a first priority. You may want to push them to help the e and f pawns to advance.
Regarding "Cutting-off the opponent's king", in rook and pawn endgames it is usually much more important to cut off the opponent's king vertically not horizontally. You want to cut off the king from where the pawn or pawns are going to be. The White king on the 3rd rank is not cut off. If you are going to make a queen then sooner or later one of your pawns is going to have to try and reach the 3rd rank when the White king would be ideally placed. The white king on the a or b file would be cut off.
Your king is already protecting your pawns but your rook is not attacking your opponent's pawns. In the changed position with White's king now protecting the g pawn the best way to attack the pawns is not the immediate Rb2 because there is a more efficient way to do that.
First Rb3+ either forces the king to the fourth rank or to the second rank. In either case the move Rb2 then comes with tempo. The White king has to move.
Then you want to try and push f6 or f5 to get your e and f pawns rolling. Your king will need to be out of the way on g6 and you will want to move the h and g pawns up so they aren't vulnerable to attack by the rook. So g5 creates space on g6 for your king. You can follow up with h5 and then get ready to push the f and e pawns. Your opponent can try and stop this by g4 or just sit and wait passively.
One line might be:
[fen "8/R4ppp/4pk2/1r6/8/5K2/6PP/8 b - - 4 38"]
1... Rb3+ 2. Kg4 Rb2 3. Kf3 g5 4. h3 h5 5. g4 (5. Rc7 g4 6. hxg4 hxg4 7. Kxg4 Rxg2) Rb3+ 6. Kg2 h4 7. Ra6 Rg3+ 8. Kh2 Kg6 9. Rb6 Re3 10. Ra6 f6 11. Rb6 e5 12. Ra6 Rf3 13. Kg2 Rd3 14. Rb6 Kf7 15. Ra6 Ke7 16. Rb6 Rd6 17. Rb2 Ke6 18. Rf2 (18. Re2 Rd4 19. Rf2 e4 20. Rf5 Rd2 21. Kg1 Rd3 22. Kg2 Rg3+ 23. Kh2 e3 24. Rf1 e2 25. Re1 Re3) e4 19. Re2 Ke5