The book of Esther - An example of God's perfect timing.

And the king loved Esther above all the women, and she obtained grace and favour in his sight more than all the virgins; so that he set the royal crown upon her head, and made her queen instead of Vashti... Esther 2:17
God positions Esther as queen, in preparation for the protection from certain death of Mordecai and the Jewish people. Only God could foresee this coming and only God could set the perfect stage, as He does daily in our lives if we let Him.
In those days, while Mordecai sat in the king's gate, two of the king's chamberlains, Bigthan and Teresh, of those which kept the door, were wroth, and sought to lay hand on the king Ahasuerus... Esther 2:21
Mordecai reveals a plan to kill the king, receiving no reward or thanks, forgotten, or so it seems. God has other plans for his recognition. All in His timing and according to His perfect plan, if we interfere not.
If it please the king, let it be written that they may be destroyed: and I will pay ten thousand talents of silver to the hands of those that have the charge of the business, to bring [it] into the king's treasuries... Esther 3:9
Mordecai makes deadly enemy with Haman because he will not bow down to him, only his God.
Then said Zeresh his wife and all his friends unto him, Let a gallows be made of fifty cubits high, and to morrow speak thou unto the king that Mordecai may be hanged thereon: then go thou in merrily with the king unto the banquet. And the thing pleased Haman; and he caused the gallows to be made... Esther 5:14
Things look a little grim for Mordecai, for in the morning he was to be hanged. No matter how the situation appears to be, those who trust in the Lord need not fear, for God is able to do all things, according to His perfect will and plan.
On that night could not the king sleep, and he commanded to bring the book of records of the chronicles; and they were read before the king... Esther 6:1
The very night before Mordecai is to be hanged, his heroic efforts are recognized by the king, and on the day of his supposed hanging, he is paraded around like a king by the one who wished him hung. Talk about God's awesome intervention. Haman is hanged on the very gallows he built for Mordecai, and Mordecai is exalted next to the king.
The value of our patience and reliance on God and His timing, and His will, and His plan is invaluable.
Praise God, and the next time you think everything is going wrong, make sure God is first, and your heart is loyal, then sit back, wait and watch God work.