(And had your Lord willed) meaning `O Muhammad, if it had been the will of your Lord, He would make all the people of the earth believe in what you have brought to them. But Allah has wisdom in what He does.' Similarly, Allah said:
(And if your Lord had so willed, He could surely have made mankind one Ummah, but they will not cease to disagree. Except him on whom your Lord has bestowed His mercy and for that did He create them. And the Word of your Lord has been fulfilled (His saying): "Surely, I shall fill Hell with Jinn and men all together.") (11:118-119) He also said,
In the seventh verse (98), the heedless deniers of truth have been admonished for their failure to make the optimum use of the time of life allowed to them. There was still time for them to leave denial and contumacy. Otherwise, an ominous time was due to come when they will make Taubah but their Taubah will not be accepted. They will say that they believed but their belief will not be welcome. And that time will be the time when the punishment of the Hereafter will appear right before their eyes at the time of death. It was in this connection that an event relating to Sayyidna Yunus (علیہ السلام) and his people was mentioned - that has good counsels and great lessons in it.
‘Had your Lord pleased, all the people on earth would have believed in Him,’ means that it was possible for God to have made the system of the world of human beings one in which everything is completely regulated by the commands of God. But, with regard to human beings this is not at all the scheme of God, which is to keep man in a free atmosphere, give him the opportunity to obey God of his own free will and voluntarily perform the tasks which the rest of the world does under compulsion. The eternal bounties of Paradise are to be obtained at the cost of this voluntary obedience. ‘No soul can believe except by the will of God,’ means that, in the present world, man will be granted the blessing of Faith only on his adopting the method laid down by God for this purpose. In the present world, the way for man to be blessed with Faith is by his using his mind to understand the call to the Faith. The mind of an individual which is swamped by worldly considerations is as if immersed in mud. There is no question of such a person being blessed with the bounty of Faith.
Uthmani text of the Madinah mushaf (King Fahd Complex). Translation: Saheeh International. Tafsir via Quran.com.