To Guide People to the Service of God
We were not created only to eat, drink, and reproduce; these are natural facts of our life and natural needs. Our main purpose is to recognize and serve God. All Prophets were sent to show us how to do this: We never sent a Messenger before you except that We revealed to him: "There is no god but I, so serve Me" (21:25), and: We sent forth among every nation a Messenger, saying: "Serve God, and eschew taghut [idols and tyrants, Satan and his followers]." Then some of them God guided and some were justly disposed to misguidance (16:36).
God sent Prophets to guide us to His service. Their missions were the same. However, whereas the earlier Prophets were sent to their own people and for a set period, Prophet Muhammad was sent as a mercy to humanity and jinn, and for all time.
According to an authentic narration, Ibn Mas'ud reports the following incident concerning the Prophet's preaching to the jinn:
Once God's Messenger and I went somewhere. He drew a circle around me and told me not to leave it until he returned. He left, and after a while some tumult broke out on the other side. I wondered whether something had happened to him, but as he had told me to stay put until he returned, I did so. Some time later, God's Messenger returned and I asked him about the uproar. He replied: "The jinn have believed and taken the oath of allegiance to me. When some of them insisted on unbelief, fighting broke out. The uproar you heard was the fighting. This implies that my life is about to end." 
God's Messenger used this last sentence to indicate that he had been sent to open the way to the guidance of humanity and jinn. Once this had been accomplished, there would be no reason for him to live, for he would have nothing more to accomplish. This also implies that believers should never neglect their essential duties here, and should pray, as instructed by God's Messenger: "O God, make me die if death is good for me; or else, make me live long as long as living is good for me!' 
 Bukhari, Marda, 19; Muslim, Dhikr, 10.
- Created on .