The first of the five major epochs of time is termed the “two thousand years of chaos” or lawlessness . It’s epitomized by the period in cwhich we were enslaved in Egypt, since it’s the time when “G-d’s presence was (so) completely concealed from the world” that it seemed “as if He’d abandoned (it) and was neither observing or paying attention to humankind’s actions” as Ramchal portrays it . Divine Justice just didn’t seem to hold sway in the world.
But that wasn’t the case, for the truth of the matter is that we had to experience slavery for various reasons, so Divine justice did operate indeed then (though in more obscure ways) . For at bottom G-d always indeed pays attention to and reflects upon His creatures “whom He loves dearly”, Ramchal assures us. It’s just that in the course of that first era G-d hid His presence most especially, withheld His full justice, and allowed for lawless chaos.
Before we go on to lay out the other epochs of time, though, we’ll need to raise the following question: How could G-d be said to have exhibited Justice on any level then, given that His presence was hidden, thus ensuring that wrongdoing would come about ?
But G-d could have reacted to wrongdoing of that level in two ways. He could have allowed it to get so completely out of hand that it would seem to have taken over the reins all together (G-d forbid), or He could have seen to it that while it would indeed go on, wrongdoing would still and all serve a good and purposeful end.
Ramchal underscores the fact that G-d chose the latter. He allowed for injustice to go on, but He set things up so that it would eventually serve His ultimate goal of eventual perfection. He instituted a Torah-based system of recompense that would purge the human soul of sin in the meanwhile, yet eventually allow for full goodness.
The point is that G-d’s hiding His presence in the course of the two thousand years of chaos didn’t ensure wrongdoing — it allowed for it to be sure, but it also allowed for recompense for it and for justice to eventually reign .
Don’t consider G-d stern and stringent, though, for things could have functioned wholly otherwise. Anyone guilty of wrong and injustice could be utterly blotted out and obliterated rather than forced to suffer commensurately. But that would not fit into G-d’s plans for the rectified world.
Just recall that despite His turning His back from it from time to time, G-d doesn’t at all abhor the world or ever wish for it to be undone. He may seem to “disappear”, to be sure, but He always steers the world in the direction of perfection.
And know too that just as Jacob bewailed the loss of his beloved son Joseph who seemed gone forever (Genesis 37:34) when he needn’t have in fact, since Heaven was planning great things for Joseph and his people, so too is G-d readying our deliverance right now even as He allows for wrongdoing.
 See Sanhedrin 97a for reference to this. Also see R’ Goldblatt’s note 45 here (as well as notes 62-63 on p. 485 of his edition) and R’ Shriki’s notes 1110-111 for Kabbalistic references.
 That is, given that the descendants and Abraham, Isaac and Jacob couldn’t fulfill their ancestors’ mission to spread word of G-d’s oneness and omnipotence; and given that idols were fervently worshiped and a human being — Pharaoh — declared himself to be G-d, it seemed as if G-d had indeed deserted the world.
There were periods of time within the 2000 year epoch when Divine Justice did certainly seem to be in place, as when Adam and Eve, Noah’s generation, and the generation of Tower of Babel were judged and made to account for their ways. But that was overshadowed by the terrible injustice of the centuries-long enslavement of the Jewish Nation.
 We had to endure the tribulations of slavery to be ready enough to draw close to G-d and inherit His Torah much the way anyone on a vital mission has to be in shape, toughened, and weathered enough to handle the exigencies of the task ahead of him. (Also see the reference to Joseph’s ironic role in all that at the end of this chapter.)  That is, how could G-d have been said to have exhibited loving kindness and justice in that instance when we’ve learned that G-d’s hiding His presence is the very thing that brings on all wrong and injustice in the first place (see 3:3:2 and elsewhere)?
 Which answers the question above of how could G-d be said to have exhibited Justice then, given that His presence was hidden, and wrongdoing was thus sure to come about as a consequence.
Rabbi Yaakov Feldman has translated and commented upon “The Gates of Repentance”, “The Path of the Just”, and “The Duties of the Heart” (Jason Aronson Publishers). His works are available in bookstores and in various locations on the Web.