For he is the minister of God to thee for good. But if thou do that which is evil, be afraid; for he beareth not the sword in vain: for he is the minister of God, a revenger to [execute] wrath upon him that doeth evil.
Note 6 at Ro 13:4: The Greek word that was translated "minister" here was also translated "deacon" and "servant." Government officials, including the police and army, were ordained by God to minister to us. The Lord uses this civil authority to protect us and execute His wrath on the ungodly. Knowing this gives us added assurance when we pray for justice to be done through the judicial system (1Jo 5:14-15).
When people fail to respond to the conviction of the Holy Spirit, we can pray that the Lord will use the legal system to stop their evil ways. Those in the legal system are ministers of God. Many thousands of prisoners have praised God for the prison term that finally stopped them and made them come to grips with the real problems of their lives.
Note 7 at Ro 13:4: The sword that is being spoken of here is symbolic of power to restrain or kill. That is what swords were used for. God has delegated some of His power to rule to governments, even to the extent of taking life.
The Lord told Noah that any person who murdered another had to die at the hand of mankind (Ge 9:5-6, see note 2 at Ro 13:1). Likewise, this verse shows that God has given government the right to use force and execute His wrath, which would include capital punishment. Even some wars can be justified on the basis of this scripture (see note 6 at Joh 18:36).
Therefore, Christians can serve as police officers or soldiers as long as they are enforcing what is right.