Psalm 126 is a joyous song. You can almost hear the up-tempo beat and see everyone dancing, jumping, and skipping to this musical delight as they went to Jerusalem and the Temple for the pilgrimage festivals. It has a classic statement/response style and would have had everyone in the group singing along. (I will italicize the response parts below.)
If I could pick a writer or when it was written, it has to be Ezra the priest in the time of Cyrus of Persia. This comes at the end of the seventy years of exile predicted by Jeremiah. This book rightfully follows 2 Chronicles 36:22-23. Jeremiah was dead. Ezekiel probably was dead, but Daniel was an old man (Daniel 10:1) and I can imagine the joy he had in seeing the captives returning to Jerusalem. (Reference Daniel 9:1-3) I forget these three prophets lived and spoke during the time in Babylon and the fall of Jerusalem.
My NIV has, in its footnotes, that verses one and four could be different, so I will use the KJV and change those two verses.
1When the Lord turned again the captivity of Zion, we were like them that dream. (When the Lord restored the fortunes of Zion, we were like men restored to health.)
2 Then was our mouth filled with laughter, and our tongue with singing: then said they among the heathen, The Lord hath done great things for them.
3 The Lord hath done great things for us; whereof we are glad.
4 Turn again our captivity, O Lord, as the streams in the south. (Restore our fortunes, O Lord, like streams in the Negev.) NIV
5 They that sow in tears shall reap in joy.
6 He that goeth forth and weepeth, bearing precious seed, shall doubtless come again with rejoicing, bringing his sheaves with him.