Allah tells us that He is the Creator, Sovereign and Controller of the heavens and the earth.
Whatever he wills happens, and whatever He does not will does not happen. He gives to whomsoever He wills and withholds from whomsoever he wills; none can withhold what He gives, and none can give what He withholds, and He creates whatever He wills.
يَهَبُ لِمَن يَشَآءُ إِنَـثاً
(He bestows female upon whom He wills.) means, He gives them daughters only. Al-Baghawi said, "And among them (those who were given daughters only) was Lut, peace be upon him."
وَيَهَبُ لِمَن يَشَآءُ الذُّكُورَ
(and bestows male upon whom He wills.) means, He gives them sons only. Al-Baghawi said, "Like Ibrahim Al-Khalil, peace be upon him, who did not have any daughters."
The earlier three of the above verses state the end of those people who, as against the virtuous Muslims, remained desirous of the delights and luxuries of this world, instead of caring about the Hereafter. Then in verse 47, they have been advised to repent and embrace faith before the scourge of Doomsday comes upon them. Thereafter, in verse 48, the Holy Prophet ﷺ has been comforted and assured that if these people do not come to their senses, despite your preaching again and again, and despite your tireless efforts, then you should not worry: فَإِنْ أَعْرَضُوا فَمَا أَرْسَلْنَاكَ عَلَيْهِمْ حَفِيظًا "So, if they turn away, then We did not send you as a supervisor over them. You are not responsible but for conveying the message" - 48.
Religion is based on the concept that every kind of power in the universe resides in the one and only God. Apart from Him, nobody else has any powers—whether these powers relate to managing the systems of heaven and earth or granting children to a human being. Whatever a man receives is at His behest and He alone may take it away whenever He wishes. It is only this belief about God which develops in man that right type of feeling which is known as submissiveness, and it is this attitude towards God which compels a man to adopt in life that behaviour which is commanded by the divine code of conduct.
Uthmani text of the Madinah mushaf (King Fahd Complex). Translation: Saheeh International. Tafsir via Quran.com.