Bismillah.
فَمَن كَانَ يَرْجُو لِقَاءَ رَبِّهِ فَلْيَعْمَلْ عَمَلًا صَالِحًا وَلَا يُشْرِكْ بِعِبَادَةِ رَبِّهِ أَحَدًا
So, whoever hopes to encounter his Lord—let him act righteously and not associate anyone with the worship of his Lord.
(Sūrat al-Kahf No. 18, Āyat 110)
According to this verse, the person who hopes to meet his Lord needs to do two things: perform good deeds and not set up any partners with Allah ‘azza wajall. Accepting religion and fulfilling its obligations is a result of having hope in the possibility of going back to Allah. This does not necessarily mean having conviction. Just the possibility of that happening keeps a person conscious of the need to be ready for it.
The word rajā’ means to have hope for something that may occur. ‘Allāmah Tabātabā’ī in Tafsīr al-Mīzān says that the word rajā’ is like tama‘(desire, craving) or amal (hope, ambition). It is an anticipation of good. There cannot be hope in something without planning for it or preparing for it. Having hope in a harvest means preparing the land and looking after the vegetation. It is foolish to have hope in something without putting in place that which will make the hoped-for event successful. Imam Ja‘far al-Sadiq ‘alayhis-salām says: He who hopes for something should work for it, and he who fears something should escape it.
Having hope in the meeting with Allah subhānahu wata‘ālā means planning for the meeting to be successful. Actions in life are in accordance with that hope. The verse mentions good deeds as well as not associating anyone with Allah. The good deeds that are performed because of having hope in the meeting with Allah must be done for the sake of Allah (swt) only. Sa‘īd b. Jubayr narrates that Prophet sallallāhu ‘alayhi wa-ālihi wasallam, said: Your Lord says; ‘I am the best partner. I will leave all the work of anyone who associates anyone from My creation with Me in his work (to that associate) and will only accept that which is for Me alone.’ The Prophet (s) then recited the above verse. (Al-Mīzān, v 26, p 217). Tafsīr al-‘Ayyāshī clarifies this theme by stating that: God says, “I am the best partner. The work of anyone who works for Me and another is for the one he did the work for, not Me.” (Ibid).
Let this verse remind us of the need to have hope in the meeting with Allah. It will be enough to help us live a God conscious life. Perhaps that is why the Prophet (s) said about the last verse of al-Kahf: If nothing but the end of Sūrat al-Kahf had been revealed to my nation it would have been enough for them.
Sources: Allāmah Muhammad Husayn Tabātabā’ī, Tafsīr al-Mīzān; https://al-islam.org/ahlul-bayt-ethical-role-models-sayyid-mahdi-sadr/hope-god