For tourist location it work. Government gets the money back in sales and other taxes. But in other cities it will be money pit with no possible way to recoup the cost. It can never work in rural areas because there isn't a dense enough population.
> it will be money pit
This is not a given at all. You have to consider the cost of enforcing the payment system. If transport is free you don't have to maintain the turnstiles and gates, employ verification agents, create cards, print tickets, etc. It's not clear at all that fares are covering this cost by themselves. Public transport is already greatly subsidized and already free or cheap for large parts of the population (elderly, disabled, unemployed, students, children).