I heard this phrase in the "Pirates of the Caribbean" and also found it online by googling it.
What does the phrase mean?
It means that a person keeps their motivations a secret. It comes from poker: you hold your cards close to your "vest" or body so you don't "tip your hand" or accidentally allow the other players to see your cards.
This is a really nice article about the phrase, and includes some related poker phrases.
Note: The linked article is The Maven's Word of the Day from August 25, 2000. This series of articles was published by Random House between 1996 to 2001. I cannot find an online archive (other than the Wayback), although I will continue to look.
The Wayback Machine hung for me, but their "Getting Impatient" link worked just fine.
Incidentally, the article ends by mentioning several poker-based idioms (e.g., lay your cards on the table, wear your poker face, etc.). Conspicuously absent, though, was the term "all-in," which seems to have gained traction more recently (the article is more than a decade old now). Still this emphasizes how poker-inspired idioms are STILL making their way into everyday speech.