In short, marketing strategies.
Here are some things that should be noted about demonetization, maybe it will shed a better light.
1) The objective of the move kept shifting arbitrarily
Initially the move was said to be against black money and terrorist activities. Then somehow the goal shifted to raising tax awareness and promoting a less-cash economy. So basically, wherever the arrow landed was declared as the target.
2) Support of the public
The public actually believed that standing in lines near cash machines was actually helping their economy. Intense rhetoric relating demonetization to sacrifice and nationalism was generally in the public domain. Although expert opinion of economists like Amartya Sen on the move was not favorable, large scale engagement of public made it seem like a revolution! Academics like Akshay Mangala have called this 'politics of visible disruption'.
For example, Narendra Modi's own 95 year old mother stood in line. This collected a lot of public sympathy.
3) Weak opposition
The Bharatiya Janta Party was quite popular at the time of this move. They had very good numbers in the 2014 elections. Also, political parties opposing and protesting against the move were alleged to be the ones hoarding cash themselves! This strategy discredited their protests.
4) Government marketing
Schemes were divised to promote cashless payments. There was a lottery scheme for users of the Bhim app, the government sponsored payment app. The government also conducted a questionable survey on the Narendra Modi app and declared that the public favored the move.
5) (Opinion) Biased media
The last one is my opinion. During the whole event, I witnessed a lot of news channels hounding the opposition and declaring demonetization as a patriotic act, a great move, etc. I think this has also worked in the favor.