It's an outdated saying but still holds meaning. Like these days saying "send the horse to the glue factory". Way back when it was more common since glues were made from horse parts
Earth society amongst itself was rid of a need for currency. However, other cultures/species within the galaxy (most notably the Ferengi), still operated under a system of exchange. Anything the Federation couldn't barter for, required some form of compensation. Credits, however they were denoted, were used to maintain the galactic economic flow. Even on DS9, Federation members were allotted a kind of stipend to be spent with the various merchants.
To bet (someone) credits to navy beans meant to put up something of high value against an equal number of relatively worthless items. Metaphorically, it indicated one's strong belief that the statement which followed was true.
A Federation variation on "dollars to doughnuts", this referred to wagering something of value against something relatively worthless – in other words, "I'll bet you anything…"
In 2267, DeSalle was willing to bet credits to navy beans that using USS Enterprise's impulse engines to crash the starship into a force field surrounding them could at least manage to put a dent in it, if not break through it. (TOS: "Catspaw")