God decided to create and send humans to earth (by sending Adam to earth) in a form that some of them being enemy of some others. So because of this form of creating humans so they naturally create each other.
[Allah] said, "Descend from Paradise - all, [your descendants] being
enemies to one another. And if there should come to you guidance from
Me - then whoever follows My guidance will neither go astray [in the
world] nor suffer [in the Hereafter]. http://tanzil.net/#20:123
Such nature is needed for testing humans. At end of this verse God talks about guidance and testing humans.
Humans have worldly greed. One of them is defeating the enemy. Humans love to kill his enemy. But when God says you should not kill that enemy of yourself, this is a test of God. Without such natures testing humans will not be possible.
Regarding a child killed and losing the possibility of higher ranks after death we are not sure that they really lose that rank. Perhaps God recovers this losing of possibility of reaching higher ranks and grants that ranks to that killed child without even worshiping God in worldly life.
In fact, this question has an assumption about God (God will not let killed children to have higher ranks at hereafter) that it is not known to be true.
O you who have believed, avoid much [negative] assumption. Indeed,
some assumption is sin. And do not spy or backbite each other. Would
one of you like to eat the flesh of his brother when dead? You would
detest it. And fear Allah; indeed, Allah is Accepting of repentance
and Merciful. http://tanzil.net/#49:12
There are different hadiths saying such children will enter paradise.
Will the children killed by prophet Khizr a.s. enter the paradise?