There's a hadith, or saying by the Prophet Muhammad (pbuh) that I only recently understood and fell in love with its beauty and the wisdom behind it.
'If the Hour were to occur and you had a seed or a small plant in your hand, (you would plant it) and if your are bale to plant it before that, then plant it (now).'This is one of my favorite teachings by the Prophet Muhammad (pbuh) because it perfectly exemplifies the wisdom and divinity of his teachings. Here, the Prophet (pbuh) is reminding people that it does not matter the outcome of ones actions, or the reward one gets from doing something, what matters is the effort one puts into anything and the intention they had. So for example, you put the effort into planting that seed, so even if the Hour occurs, you are still rewarded for the effort you put into planting that seed.
It's not the ends but rather the means.