Elisha could not tell what would be the effect of his curse. It could have no effect at all excepting through the will and by the action of God. And there came forth two she-bears out of the wood; or, the forest; i.e. the forest, which, as all knew, lay within a short distance of Bethel, and was the haunt of wild beasts (see 1 Kings 3:24). And tare forty and two children of them. It is not said how far the lads were injured, whether fatally or not. But the punishment, whatever its severity, came from God, not from the prophet, and we may be sure was just. For "shall not the Judge of all the earth do right?" A severe example may have been needed under the circumstances of the time, when a new generation was growing up in contempt of God and of religion; and the sin of the lads was not a small one, but indicated that determined bent of the will against good, and preference of evil, which is often developed early, and generally goes on from bad to worse (Pulpit Commentary).
The comments below are from the late J. Hampton Keathley III:
"'Young lads.' The KJV has 'little children' which really misses the meaning here. These were not children, but young men. The word 'lads' is the Hebrew naar and was used of servants, of soldiers and of Isaac when he was 28 years old. This was a crowd of young men, perhaps students of the false prophets, who were here as antagonists to Elisha's prophetic ministry and authority. If not students, they were sent by the false prophets or idolatrous priests of Bethel to stop Elisha from entering the city. In Elisha Satan had an enemy and he was acting to protect his territory. Remember, however, Elisha was going to Bethel not to curse, but to bless."
"So Elisha, as a prophet, saw their hardened and rebellious condition, unresponsive to correction. In the name of the Lord (i.e. by His authority) Elisha simply turned them over to the Lord and to their own devises, which had the effect of removing them from even the common protection of God. He probably said something like, 'may God deal with you according to what you deserve,' or 'may you be cursed for your sins of rebellion.' This would demonstrate to the city and to people all around a vital truth: without the Lord there is no protection and that blasphemy of God's servants and His Word in order to hinder God's message is serious business. Note that Elisha did not call out the bears, God did. Two female bears (not three bears--papa bear, mamma bear, and baby bear) came out and tore up forty-two young men."