This is why when the sister of ‘Uqbah bin ‘Amir made a vow to perform Hajj walking barefoot, the Prophet (sallallahu alayhi wasallam) said: “Indeed, Allah is not in need of your sister torturing herself. Have her continue while riding.” It was narrated that he had her slaughter an animal, and it was also narrated that he had her fast. The same applies to the hadith of Juwayriyah when she was performing tasbih using pebbles before noon, and he came back at night and found her sitting in the same position. So, he said to her: “I said four words three times that would outweigh all that you have said today.”
The point of all this is to know that Allah didn’t command us to do except what is beneficial for us, and He didn’t forbid us except from what is harmful to us. This is why Allah praises righteous acts and encourages righteousness and benefit, and discourages corruption and harm. Allah forbade us from filthy things due to the harm and corruption they bring about, and He commanded us with righteous acts due to the benefit they bring about.
It might be the case that such actions cannot be performed except with some hardship, such as enjoining the good, preventing the evil, seeking knowledge, etc. So, all of this is obtained through hardship, and one is rewarded for them due to the benefit that they result in. This is like when the Prophet (sallallahu alayhi wasallam) said to ‘A’ishah when she performed ‘Umrah from at-Tan’im in the year of the Farewell Hajj: “Your reward is in accordance with your effort.”
However, if the benefit of the act does not outweigh the hardship it involves, this is a form of ruin and corruption, and Allah does not love corruption. An example of this is in worldly benefits. Enduring hardship to make a great gain or repel a great enemy is praiseworthy. As for one who endures great effort and hardship in order to make an insignificant amount of money or to repel a very minor harm, he is just like a person who pays a thousand dirhams in exchange for a hundred, or one who walks for an entire day to get a meal while he could’ve gotten a better meal in the very town he lives in.
So, the legislated and recommended course of action is all about justice, balance, and moderation – which are the best and loftiest of affairs – just as the Firdaws is both the highest part of Paradise and the middle (i.e. best) part of it. So, whoever is like this will have this as his destination, by Allah’s Permission"
Ibn Taymiyyah (rahimahullah)
(Majmu’ al-Fataawa’ ibn Taymiyah; 25/126-127)