I've been subjected to the ridiculous wallet inspection as well. Did it go something like
this?
I assume they're checking for either "contraband" or what they deem to be an inappropriate about of money. They best way to avoid it is to pace your wallet in a carry-on that goes through the x-ray and hope they don't decide to do a bag check.
TSO: "I can't believe that worked!"