All perfect praise be to Allah, The Lord of the Worlds. I testify that there is none worthy of worship except Allah, and that Muhammad is His slave and Messenger.
The best thing that a Muslim gains from relying on Allah and having trust in Him is that he achieves important aspects in his religion, like achieving the worship of Allah and obeying the Commandment of Allah Who ordered him to rely on Him after taking the means that he is able to undertake.
In addition to this, relying on Allah yields in his heart comfort, tranquility and trust, so he is not affected by worries or psychological diseases and he does not commit suicide just because he missed something of his worldly life.
However, the non-Muslim whom you mentioned that he does not believe in the existence of Allah and he does not rely on Him, he is prevented from all these benefits. It is for this reason that many non-Muslims commit suicide when they fail and despair from achieving the target.
For more benefit on some religious texts which command us to rely on Allah and clarify its importance in the Muslim society, please refer to Fatwas 17855 and 44824.
Secondly, in Islam taking the means is not separate from relying on Allah; rather, taking the means is part of relying on Allah, so one of them should not be neglected for the other. Indeed, our scholars said: “Relying only on the means is Shirk (associating partners with Allah), and denying them is foolishness; everything is in the hands of Allah, so being enabled to achieve something cannot be realized just by doing the means; rather, achieving one’s target may not happen despite taking all the means as Allah, The Almighty, is able to invalidate the means and prevent its results. It is for this reason that the fire did not harm Ibraaheem (Abraham), may Allah exalt his mention, when he was thrown in it, and Prophet Yoonus (Jonah), may Allah exalt his mention, was not harmed while he was in the belly of the fish, and Khaalid ibn Al-Waleed, may Allah be pleased with him, drank the poison while relying on Allah and it did not harm him.”
Now if we take the case of the non-Muslim whom you mentioned to us as an example, then Allah may afflict him with something that distracts his mind and so he will forget much of what he had studied, or that he will develop an illness that would prevent him from completing the exam, and other things that may hamper him. So, the means will not benefit him if Allah wanted other than that. In contrast, a Muslim who relies on Allah, who knows that the matter is first and foremost in the hands of Allah, he asks Him to help him and make him firm, and so he achieves his target. Look at what happened in the Battle of Badr, how a small company has overcome a large company.
Thirdly: this worldly life is a test to distinguish and differentiate between the allies of Allah and His enemies, but Allah may give the non-Muslim (disbeliever) of this world and expands for him and realizes for him his needs despite his disbelief and despite him not thinking of Allah or relying on Him, but this is a way of progressively leading him to destruction. The evidence for this is what Imaam Ahmad reported in his Musnad from ‘Uqbah ibn ‘Aamir, may Allah be pleased with him, that the Prophet said: "If you see Allah giving a person what he loves from this world despite his sins, then this is progressively leading him to destruction," then the Prophet recited the saying of Allah (which means): {So when they forgot that by which they had been reminded, We opened to them the doors of every [good] thing until, when they rejoiced in that which they were given, We seized them suddenly, and they were [then] in despair.} [Quran 6:44]
Finally, we warn you against being dragged behind such misconceptions, and you should be keen on learning the matters of your religion and you should submit yourself to your Lord and not get involved in matters that do not concern you especially if the matter is regarding the Sharee’ah of Allah and His Acts. Allah says (what means): {And Allah decides; there is no adjuster of His decision. And He is swift in account.} [Quran 13:41] So, look at the end of the verse {And He is swift in account.} which is a clear threat to the one who objects to the rulings of his Lord.
Allah Knows best.