First of all we need to understand in what context this whole conversation is going on, this conversation is going on between King Harishchandra and Narada Muni, here King Harishchandra had multiple wives but no son, now for a King a son was important because he would rule the kingdom, go in battlefield to fight against the enemies and to led the generation forward. This was natural in those times, we need to understand that the Dos and Donts are not the eternal things in Hinduism, its philosophy and eternal teachings are considered eternal, the Dos and Donts are made according to the time, place and various circumstances, they are not the eternal truth.
There is a way of studying the shastras, by going through these stories mentioned in Brahamanas, Itihaas, Puranas, we need to follow what is applicable in present time what can led to our welfare, this is known as studying by विधिमुख, and what can't be applied should be rejected as निषेधमुख.
Coming back to the topic, here King Harishchandra asked about son with Sage Narada, now Narada muni is a very clever character, he responds according to the situation according to the divine leela that is being done. Now when King Harishchandra asked about having a son, then sage Narada started glorifying the importance of son. Even he went to say that , What is the use of living unwashed,' wearing the goatskin,' and beard '? What is the use of performing austerities ? * You should wish for a son, Brahmans ! . Now here , Narada muni is completely denying any importance of performing austerities, does that means that performing tapa, following austerities and renunciation is useless in Hinduism as Narada had mentioned so it became an eternal truth so nobody should perform austerities, only a fool will think like that. Hinduism is filled with examples of many sages who didn't marry, there is a concept of naištika brahmacārya where a sage doesn't enters into family life. So what Narada muni said was in context of that situation.
Now the lines further goes as "
Food preserves life, clothes protect from cold, gold (golden ornaments) gives beauty, marriages produce wealth in cattle ; " the wife is the friend, the daughter object of compassion, but the son shines as his light in the highest heaven.". Now the scholars, who quote the above phrase, out of context, do not bother to look at the preceding statement on wife - wife is the friend - सखा ह जाया.
Both wife and daughters are females then why was wife mentioned as friend, but daughter was mentioned as cause of misery?
The crux of the issue lies in the fact that daughter will go to another family, as another bride comes to one's family, as daughter-in-law.
The bondage between father and daughter is as strong as father and a son.
However, the son remains with the father, whereas the daughter has to necessarily move out after marriage to someone else's family, which creates unbearable sorrow. So here this is the context, even in today's bollywood movies when the farewell scene comes then sad songs are played at the background.
So, it was all just a part of divine leela in that situation, in that context in that circumstances, while reading such leela if anyone finds something useful in the conversation then he/she should accept it with विधिमुख and thinks that something isn't useful then should reject it with निषेधमुख.
There are many verses in hindu scriptures that glorifies and prays for the daughter, here are some of them
Brihadaranyaka Upanishad 6.4.17 “He who wishes that a daughter should be born to him who would be a scholar and attain a full term of life, should have rice cooked with sesame, and he and his wife should eat it with the clarified butter. Then they would be able to produce such a daughter.”
Asvalayana Grihya sutra 1.2.1-5 also mentions a ritual for birth of both son and daughter.
Rig Veda 8.31.8 “With sons and daughters by their side they reach their full extent of life,Both decked with ornaments of gold.”
Agni Purana 33.14 ” O twice born one! Otherwise twenty four or thirty six garlands should be consecrated to the sun with the ring and middle fingers by those who desire for a daughter.”
Agni Purana 325. 20-22a “By this worship, a person desirous of getting a daughter would get a daughter, a person not having a son would get a son, an unfortunate woman would get fortune….”
Atharva-veda 10.3.20 says that it is matter of glory to have Girl child.
Mahabharata, Anushasan Parva 13.47.26 says, “The daughter, O king, has been ordained in the scriptures to be equal to the son.”
Matsya Puran (2.155) further says, “Scriptures stated many times that a Daughter is equal to ten sons.”
Skandh Puran I.ii.23.46, it says “A Daughter is equal to ten sons. The merit that one derives by bringing up ten sons is obtainable by bringing up one daughter.”
Padma Puran 4.24.18-25 says that there is no escape from Hell for those who sell their daughter.
Linga Puran 5.30-33 says that the word ‘Putri’ (Putri is a Sanskrit word which means Daughter) is interpreted as “one who saves from hell”.