Why Daniel had divine protection in the lion's den
According to Daniel, God liberated him from the mouths of the lions, because he was just.
20 And when he came to the den, he cried with a lamentable voice unto Daniel, and the king spake and said to Daniel: O Daniel, servant of the living God, is thy God, whom thou servest continually, able to deliver thee from the lions? 21 Then said Daniel unto the king, O king, live forever. 22 My God hath sent his angel, and hath shut the lions' mouths, that they have not hurt me, forasmuch as before him innocence was found in me; and also before thee, O king, have I done no hurt. (Daniel 6:20-22)
Does this mean that the grave things that occur to a human being are because he has a certain injustice credited to him? A sin that was committed by him may not be directly in relation with the injustice of the suffering, but God does not deliver him from it, which is unjust, because he did not receive sufficient punishment for some sin he committed.
In synthesis, a fault or stain that a human being has or commits before God, invalidates all or part of the protection God gives us through his angels.
Since Daniel did not have a negative balance in his account, but any wrongdoings he previously committed were already paid for; the angelic-divine protection manifested itself hundred percent.
Does this mean that all bad things that come upon a person are as a result of punishment or some debt he has to pay? Not necessarily. Sometimes persons of higher merit before God can experience very hard times, in which they will serve God to demonstrate how much they love him, and they continue to love him no matter how bad their experience. This was the case with Job. But let us not think that we are all like Job.
What occurs sometimes is that the consequences of a national or social sin falls on a particular nation or society and all members are sprinkled with the punishment. Even though all of this is true, the first thing I do is not examining the society or the nation, but examine myself. As we can see, one of the blessings of holiness is to count on absolute protection from God.