Scripture teaches that people are to submit to authority as is appropriate. There are several examples given in the Bible. Men to God, citizens to the king or the state, children to parents, slaves to masters, church members to elders. And by analogy other situations such as employees to employers.
I think there is a good argument to be made to obey authorities in most situations, even if the authority is not righteous. I will not defend this position here, it is a common position among Christians, though I am aware there are arguments otherwise.
Let every person be subject to the governing authorities. For there is no authority except from God, and those that exist have been instituted by God. Therefore whoever resists the authorities resists what God has appointed, and those who resist will incur judgment. For rulers are not a terror to good conduct, but to bad. Would you have no fear of the one who is in authority? Then do what is good, and you will receive his approval, for he is God’s servant for your good. But if you do wrong, be afraid, for he does not bear the sword in vain. For he is the servant of God, an avenger who carries out God’s wrath on the wrongdoer. Therefore one must be in subjection, not only to avoid God’s wrath but also for the sake of conscience. For because of this you also pay taxes, for the authorities are ministers of God, attending to this very thing. Pay to all what is owed to them: taxes to whom taxes are owed, revenue to whom revenue is owed, respect to whom respect is owed, honor to whom honor is owed. (Romans 13)The question arises about what someone should do when he is commanded something that conflicts with a higher authority he is answerable to.
While we are answerable to those above us, we may also be answerable to those above them. The basic structure I see is this:
Some structures are voluntary and others compulsory. Compulsory structures may change. All governments are always under God, as are all men. Christians are under their elders, but they are free to leave their local church, or even Christianity. Slaves are not free to leave, but employees are. Children become adults and are no longer answerable to their parents. A voluntary structure does not permit you to disobey your superiors, though you are free to leave the structure if you find their requirements repulsive.
The flow of authority means that people are permitted to disobey an immediate authority if obedience to him means disobedience to a higher authority. However it must result in disobedience to the higher authority, not just inconsistent with his preferences. Further, you must also be under the higher authority.
So if you are a slave to a soldier who is under a commander, but you are not answerable to the commander in any way, then you do not need to take the commander's objection into consideration in your obedience to the soldier. Though it may be prudent to consider the likely consequences.
If you are also answerable to the commander, and the request of the soldier is inconsistent with how the commander would act, but performing such a task would not mean you are disobeying the commander, then the duty to obey remains in effect.
One can transfer authority. When discussing this with my daughter I used the example of school. I transfer my authority over my daughter to the teachers and principal during her time at school. The teachers are not under my authority at all. Still, because I am the primary authority over my daughter, she is allowed to disobey her teachers in deference to me.
It is also important to note that people have authority if they are delegated it, not because they are part of a structure. In a monarchy the king is the ultimate authority (under God), but the king's attendants do not necessarily carry any power. A person working for the state does not have intrinsic authority based on his employment, it is based on his position. So a policeman or a judge has authority delegated by the state, and government teacher does not.
This is how I see God has set up the authority structures on earth. And while it is appropriate to disobey an authority to obey a higher one,
But Peter and the apostles answered, "We must obey God rather than men...." (Acts 5),it is important that this only be the case when obedience to the lower authority would constitute active disobedience to higher one. There are many situations where authorities abuse their power and request things that are not ideal, things that a better steward would not command of his subjects. But it is these authorities who are answerable to those above them. It is no sin to obey a wicked ruler in some of his poorer rulings, in fact it may be a sin not to obey him.