Just as giving in charity what one loves is beloved in the sight of God:
Al Imran 3:92: لَن تَنَالُوا الْبِرَّ حَتَّىٰ تُنفِقُوا مِمَّا تُحِبُّونَ وَمَا تُنفِقُوا مِن شَيْءٍ فَإِنَّ اللَّهَ بِهِ عَلِيمٌ
“You will never attain true righteousness unless you give in charity some of what you love. Whatever you give, God knows it.”
Likewise, sacrificing a child for whom one feels such deep love and affection is a sign of surrender and of a love for the Exalted Creator that surpasses all other love.
Al-Baqara 2:207: وَمِنَ النَّاسِ مَن يَشْرِي نَفْسَهُ ابْتِغَاءَ مَرْضَاتِ اللَّهِ وَاللَّهُ رَءُوفٌ بِالْعِبَادِ
“Among people are those who give themselves up in pursuit of God’s pleasure—and God is most compassionate towards His servants.” This refers to people of faith and self-sacrifice, such as Ali (AS), who on Laylat al-Mabit slept in the Prophet’s place.
A child is dearer to a person than their own life!
بنفسی انت و امی و ابی و اولادی و اموالی
What matters is that the sweetness of love for one’s children should not keep one from love and devotion to God.
Al-Munafiqun 63:9: يَا أَيُّهَا الَّذِينَ آمَنُوا لَا تُلْهِكُمْ أَمْوَالُكُمْ وَلَا أَوْلَادُكُمْ عَن ذِكْرِ اللَّهِ وَمَن يَفْعَلْ ذَٰلِكَ فَأُولَٰئِكَ هُمُ الْخَاسِرُونَ
“O you who believe, do not let your wealth or your children distract you from the remembrance of God. Those who do so are the losers.”