Consoling His Messenger for the rejection of the disbelieving Quraysh, Allah says that He has sent Messengers before him to the nations of the past, and no Messenger came to a nation but they rejected him and mocked him. Then He tells him that He lets disbelief enter the hearts of those sinners who are too stubborn and too arrogant to follow His guidance.
(Thus We allow it to enter the hearts of the guilty.) Anas and Al-Hasan Al-Basri said that this referred to Shirk.
(and already the example of the ancients has gone forth.) meaning the destruction wrought by Allah on those who rejected His Messengers, and how He saved His Prophets and their followers in this world and in the Hereafter, is well known.