This is certainly a reasonable question. I will have to say that my first emotional response to this commandment is to say that it certainly seems harsh. I am not sure about cruel, but certainly it appears harsh or like an over reaction from my own Western, human perspective.
In order to understand God’s viewpoint on this let me throw a few things out there for you to think about. First, in almost every case in the Old Testament God has physical laws with physical implications which foreshadow a spiritual teaching with a spiritual application in the New Testament. This law teaches us about God’s attitude toward his children who rebel against him. Second, there is a good analogy between a son or daughter rebelling against their father and one of us rebelling against our Father in heaven. God takes rebellion against him very seriously. God hates sin with an intensity that it is hard for us to grasp. Third, death is not really a big issue to God. From God’s perspective, death is not an end but a transition. God opposes every kind of cruelty and abuse, but we all die and God is a righteous judge. He gave us life and he has every right to take life away. Death is a tragedy for us, but not to God. What is a tragedy is that we rebel against God and end up separated from him.
Having said that, I will still have to admit that the commandment in Deuteronomy 21:18-21 still seems over the top to me. That is the honest truth. I believe that if I was living in the Near East 1400 BC I might think differently. The culture and times were very different. Life was more brutal. Another thing to think about is that as far as I know, there is no evidence that any Jewish children were ever killed for this cause. God told his people to take the rebellion of children against their parents seriously. I assume they did, but I doubt that many children, if any at all, went so far that the Jews went to the extreme of actually taking their lives. I cannot prove it but I assume that children were warned of the consequences and given many opportunities to change. I believe that it is very likely that Jewish children tended to respect their parents more that the people around them.