Jesus taught that our attitudes and motives matter to God. And how we do things can reveal our heart - sincerity, humility, purity and devotion - or a lack of these.
Making a show of our giving, prayer and fasting reveals a desire for the approval of people rather than God; God rewards us when we do these things secretly, for him alone.
Matthew 6:1-18