"If the foundations be destroyed, what can the righteous do?" (Psalm 11:3)
David writes: "If the foundations (of society) are being destroyed, what can the righteous do?"
The answer: Remain established in His righteousness:
"In righteousness shalt thou be established: thou shalt be far from oppression; for thou shalt not fear: and from terror; for it shall not come near thee." (Isaiah 54:14)
In this verse, "oppression" and "terror" refer to political tyranny, not just spiritual oppression.
The world may get darker and darker, but ...
"But the path of the just [righteous] is as the shining light, that shineth more and more unto the perfect day." (Proverbs 4:18)
Even during the Ten Plagues, when one plague brought utter darkness on the land of Egypt:
"They saw not one another, neither rose any from his place for three days: but all the children of Israel had light in their dwellings." (Exodus 10:23)
This light was the Divine Light, since a natural light could have been produced by the Egyptians, as well.
Returning to David's Psalm, David does not ask this question "What can the righteous do?" as if there is no answer.
He provides it right away:
"The LORD is in his holy temple, the LORD'S throne is in heaven: his eyes behold, his eyelids try, the children of men." (Psalm 11:4)
He is still very much on the throne, governing in the affairs of those who believe on Him.
In fact, to those who seek to undermine the foundations:
"The Lord shall laugh at him: for he seeth that his day is coming." (Psalm 37:13)
David the continues:
"The LORD trieth the righteous: but the wicked and him that loveth violence his soul hateth." (Psalm 11:5)
Yes, the Lord examines us, knowing that we will measure up, trusting in Him to see us through. The tough times reveal the perfect work which He has accomplised in those who believe in Him. Abraham was tested in Genesis 22, and demonstrated the fullness of faith!