Psalm 127:1-5 (NIV), A song of ascents. Of Solomon.1 "Unless the LORD builds the house, the builders labor in vain. Unless the LORD watches over the city, the guards stand watch in vain. 2 In vain you rise early and stay up late, toiling for food to eat–for he grants sleep to those he loves. 3 Children are a heritage from the LORD, offspring a reward from him. 4 Like arrows in the hands of a warrior are children born in one's youth. 5 Blessed is the man whose quiver is full of them. They will not be put to shame when they contend with their opponents in court."
At the time Solomon wrote this psalm, only Israel was in this covenant relationship with God (Amos 3:2). God had promised to bless the nation if obedient and punish them if disobedient. (Please read Leviticus 26.) Thus, this psalm was and is, presently, an encouragement to natural Israel to obey God.
In verse 1, God is offering special protection to a family or a city if the inhabitants are seeking to follow God’s Laws as presented in the 10 Commandments and other ordinances recorded in Leviticus chapters 1 through 27. Otherwise, worldly people may devise protective measures but their strategies may be futile against other ungodly forces and even against drought, famine, diseases, etc.
Verse 2 has two slightly different translations from different manuscripts. “It is vain for you to rise early, come home late, and work so hard for your food. Yes, he can provide for those whom he loves even when they sleep.” (NET) The sense here is God is the great provider and blesser. God will provide for His obedient children.
Verse 2 (RSV), “It is in vain that you rise up early and go late to rest, eating the bread of anxious toil; for he gives to his beloved sleep.” This (and the majority of English Bibles) reveal that God will give peaceful sleep to those who trust in Him for their necessities.
Verses 3-5 are about the blessings of having children. It is always a great joy to be able to love and nurture children. Truly, the ability to beget and birth children are a gift from God. Additionally, in Bible times, children helped to do farm work and shepherd. Healthy children, who could help the family with their natural needs, are a blessing.
The world today is not blessed by a covenant with God. Yet, it is always wise to obey God’s righteous will. To the extent any person obeys God, he will be blessed. Isaiah 56:6-7 (NKJV), 6 “Also the sons of the foreigner who join themselves to the LORD, to serve Him, and to love the name of the LORD, to be His servants–Everyone who keeps from defiling the Sabbath, and holds fast My covenant– 7 Even them I will bring to My holy mountain, And make them joyful in My house of prayer…For My house shall be called a house of prayer for all nations.” Soon, all nations will know the Lord (Isaiah 2:2-4.)