I think the answer lies in the Church’s duty to disciple the nations:
Matthew 28:18–20
And Jesus came up and spoke to them, saying, “All authority has been given to Me in heaven and on earth. Go therefore and make disciples of all the nations, baptizing them in the name of the Father and the Son and the Holy Spirit, teaching them to observe all that I commanded you; and lo, I am with you always, even to the end of the age.”
That discipleship is usually a long process. We need to faithfully obey Christ’s commission, knowing that the leaven spreads slowly and joyfully suffering in the mean time. But we need to suffer with hope as we actually do the work of teaching the nations to obey all that God has commanded. We modern American Christians have totally neglected that for generations, now.
We also need to obey the Apostle Paul’s command:
1 Timothy 2:1–2
First of all, then, I urge that entreaties and prayers, petitions and thanksgivings, be made on behalf of all men, for kings and all who are in authority, so that we may lead a tranquil and quiet life in all godliness and dignity.
In the context, I believe our prayer for the magistrates must focus on their salvation (verses 3–4: “This is good and acceptable in the sight of God our Savior, who desires all men to be saved and to come to the knowledge of the truth”). As they come to repent of their sins and know the Lord, they will be able to understand true justice and righteousness and apply it in the civil sphere (as Romans 13 requires), just like a newly-converted father begins to apply it in his home. Slow work, to be sure, but God promises to bring good fruit.