G-d blessed Joseph’s two sons Ephraim and Manasseh because they were raised according to HaShem’s word.
When Jacob sensed that he was about to die, he sent for Joseph. Jacob instructed Joseph not to bury him in Egypt, fearing that the Egyptians might turn his grave into an object of worship since it was his blessing that had ended the years of famine. Instead, Jacob instructed Joseph to bury him in the family tomb in Hebron. Some time later, when Jacob became ill, Joseph took his two sons, Manasseh and Ephraim, to Jacob in order for them to receive his final blessing. Jacob surprised Joseph by informing him that he was making Joseph’s sons the heads of two separate tribes, on an equal footing with Jacob’s own sons.
[Jacob] said to Joseph, “I dared not even hope to see your face, yet now G‑d has even shown me your children.” Genesis 48:11
Jacob intimated why he considered Ephraim and Manasseh his own sons by referring to them as “your two sons who were born to you in Egypt before I came to you.” Even though Ephraim and Manasseh were born and raised in Egypt before Jacob’s arrival, they grew up true to their grandfather’s ideals. Therefore, Jacob considered them as loyal to him and his ideals as his own children.1 Likutei Sichot, vol. 15, p. 435.