Good question. It's a confusing and disturbing story, one that seems to have rather drastic consequences for an offense that appears to us, to be relatively minor. Elisha was a prophet with the mantle of Elijah from Holy Spirit. He had to minister to ungodly people of ungodly nations and he had a lot of opposition. These weren't your ordinary children. They were probably teenagers and there were many of them (I mean 40+ are mentioned as being mauled by the two bears). They were taunting the holy man of God and bullying him - basically spitting in God's face. God showed that nation that they needed to take Elisha seriously, as he was God's messenger. If they didn't listen to Elisha and turn back to God and repent to Him, God's wrath would fall on them and there would be far worse a judgement in store for them than 40+ teenagers being attacked by bears. I hope this brief explanation helps.