The bars burst, the chains fell off and the doors burst open because they were singing hymns of praise to God. The joy of the Lord is not only our strength, it may be our deliverance and our freedom in conditions that would seem otherwise hopeless. We get weak and we even get sick. The joy of the Lord is our strength, our health, power, enablement and even deliverance. It is unconditional.
Happiness is conditional.
Joy is unconditional. The basis of their ability to sing in the midst of their adversity was their eschatological hope and expectancy. They knew that for every wound, they would receive an eternal reward. For every affliction and deprivation, there would be a corresponding reward that would not fade away. The joy of the Lord will set us free from the cell of depression, self-pity, fear and all of the kinds of things that cripple and bind us, that are more effectively a prison than a literal prison.