By no means shall ye attain righteousness unless ye give (freely) of that which ye love; and whatever ye give, of a truth Allah knoweth it well.
The purpose of this verse is to remove the misconception of the Jews concerning ‘righteousness’. The Jews had inherited an elaborate legal code which had accumulated as a result of the casuistry and hair-splitting legalism of their jurists. Their notion of ‘righteousness’ consisted of outward, formal conformity to that code and they evaluated all day-to-day actions, especially the trivial ones, in terms of conformity to that code. Narrow-mindedness, greed, covetousness, meanness, concealment of the Truth and readiness to barter with it lay beneath this veneer of formal piety. They were, nevertheless, considered pious in the minds of the people; Jewish public opinion condoned their conduct because it conformed to its concept of ‘righteousness’. @ @ In order to remove this misconception they are told that the things they considered fundamental to righteous conduct are of little consequence. The real spirit of righteousness consists in the love of God – a love which makes man value the good pleasure of God above all worldly acquisitions. If the love of anything seizes a man’s mind to such an extent that he is unable to sacrifice it for the sake of the love of God, then that thing has virtually become an idol, and until he smashes it the door to righteousness will remain closed to him. If a man lacks this spirit, then his excessively formal and legalistic approach in religious matters can be considered no more than glossy paint over a piece of hollow, worm-eaten wood. It may be possible to deceive human beings by the sheer lustre of the outer paint, but not God.
Maududi, Abul Ala (2010). Tafhim ul Quran. https://www.englishtafsir.com/Quran/27/index.html