Prophethood is a divine gift and blessing for which Allah chooses whomever He wills from among His slaves.
Allah, may He be glorified and exalted, says (interpretation of the meaning), "These are some of the Prophets whom Allah blessed from among the descendants of Adam and of those whom We carried with Nuh in the ark, and from among the descendants of Ibrahim and Isra’il, and from among those whom We guided and chose." (Maryam 19:58)
Al-Sa‘di said, “These are some of the Prophets whom Allah blessed that is, Allah bestowed upon them a blessing that no one else could attain, and a gift that cannot be surpassed, namely prophethood and the message.”
Allah, may He be glorified and exalted, said to Musa (peace be upon him) (interpretation of the meaning), "I have chosen you above others, by giving you My messages and speaking to you." (al-A‘raf 7:144) Al-Shawkani said, “What is meant by choosing is selecting him and bringing him close.” Prophethood cannot be attained by merely longing for it or by striving hard for a long time. Al-Safarini said, “The view of the people of truth is that prophethood cannot be attained merely by personal effort and trying hard… Rather it – namely prophethood and the message – is a blessing from the Almighty Lord Allah, may He be glorified and exalted, which He gives to whomever He wills of those who He knew and willed from eternity that they would be chosen for it, for Allah knows best where to place His message.”
‘Abd al-Razzaq ‘Afifi said, “It is not far-fetched, rationally speaking, and it is not impossible, if you think about it, that the Bestower of blessings would single out some of His slaves who are smart and mature in thinking, easy-going and forbearing, very patient and possessed of leadership qualities and good manners and attitudes, to prepare them to carry the burden of His message, to disclose to them what He hid from others, and to reveal to them that which will bring happiness to the people and wellbeing to all creation… And your Lord creates what He wills and chooses al-Qasas 28:68.”