The pen ink changes color if the paper is wood based. Genuine bills are printed on cotton rag.
The pen is actually testing for the presence of bleaching agents in counterfeit currency.
The use of markers dates back fairly recently to the discovery of super bills. Those were counterfeit $100 bills that were so good that they passed the federal reserves scanners without getting kicked out. The counterfeiter used the same paper by bleaching out $1 bills, the same ink and the same presses the Bureau of Engraving uses. Besdies that they all had different numbers. That kicked off the currency changes in this country starting with $100s and working down.
My guess is the marker somehow reacts to the residual chemical used to bleach the paper.