According to the Bible God sent two female bears to kill 42 children.

Technically speaking it was Elisha who cursed the children and as a result two bears came and killed them. It was not uncommon for people in those days to mock and kill someone. The same happened to Christ. He was mocked and then killed. I mention this because there is not much detail given why death would be a suitable punishment for the children, but taking this into account, that could be viewed as self defense. They obviously did not respect the prophet and intentionally went out after him, that could mean they meant him more harm than that which is mentioned. Do not be fooled by the word children, that could be any one up to 21 depending on the country you live in. But laying speculation aside, I think the best explanation was that it was done because Elisha was a prophet and prophets were given certain authorities. To understand this you must understand why the prophets were sent. Israel asked for a king when God was leading them, but in the end God allowed it. The prophets were God's mouth piece to speak to the King and nation. The king's did not always listen to the prophets because the kings were now viewed as the highest authority in the country and therefore God gave the prophets certain authorities so that the people will listen when they speak. It's like the Police force in any country. The officers are there to uphold the laws and wishes of the rulers. If the officers had no authority then what would prompt anyone to fear and respect them and keep the law? If a police officer cannot arrest you and jail you if you did something wrong by disobeying the law then what would be the purpose of having a police force? In the same way mocking a prophet of God shows that the children had no respect for the law and the Law giver. That would be equivalent to walking up to any countries leader and telling him to his face he is a fake and that you laugh at his authority and the nation he represents. I think in all cases that will be considered treason and depending on the country may result in the death of the mocker. Treason is mostly considered enough reason to give the death penalty or the severest punishment possible a country can give even today. Considering this, why then would that be a problem in Elisha's time or a problem to understand today? Terrorist's attack countries, killing innocent people, not caring about or respecting other the other nations authority and laws. People who have a problem with Elisha cursing children that gets killed because they broke the law should also have a problem with retaliating against and persecuting law breakers. The people did not have an excuse either because they were warned to fear the prophets of God. So here we have another principle. The children were not so innocent as you would think. They were warned of old, they knew the law but chose to ignore it any way. That's like a kid stealing his father's car, getting drunk and losing his life in an accident. The kid knew he should not steal, he knew he should not drink and drive but he did it anyway and lost his life. Do you feel sorry for that kid? Do you think he deserved what happened to him? After all he brought it upon himself, didn't he? As for the character of God part, I do not really see why that would explain the character of God.