The Quran tells the believers to keep to forgiveness, to turn away from the ignorant, and, when the ignorant address them, to answer 'peace'. It even forbids Muslims to insult the gods that others pray to, so that those people do not insult Allah in return out of ignorance. At the same time, it warns that those who malign Allah and His Messenger are cursed. So insult is serious, and the Quran's instruction for how to meet it is restraint.
The Prophet ﷺ set the example. When some Jews greeted him with 'al-samu alaykum' (death be upon you), Aisha answered with a curse, and he told her to be gentle, because Allah loves gentleness in all matters, and said that he had simply replied, 'and upon you'. Aisha also reported that he never took revenge for himself, and that the only exception was when one of Allah's sanctities was violated.
In law, honesty requires saying that many classical jurists held that a person who insults the Prophet ﷺ can be punished, many by death, and they pointed to cases such as that of Ka'b ibn al-Ashraf, whom the Prophet ﷺ described as having harmed Allah and His Messenger and who, according to the early biographies, had been inciting war against the Muslims. Scholars differed over details such as repentance and the treatment of non-Muslims, and a number of modern scholars limit the cases to insult joined to incitement or war. Blasphemy laws in some countries have been used to settle personal disputes and to persecute minorities, including Muslims. Mob killings have no basis in Islamic law at all.