In a letter, the former Beatle told Putin that he wrote his playful homage to the former Soviet Union in 1968, "back when it wasn't fashionable for English people to say nice things about your country."
Quoting the song's line "Gee it's good to be back home," McCartney asked: "Could you make that come true for the Greenpeace prisoners?"
The 28 protesters, as well as a photographer and a videographer working for Greenpeace, were detained aboard their ship, the Arctic Sunrise, on Sept. 18 after staging a protest at an oil rig owned by Russia's Gazprom state energy giant.
They were initially charged with piracy. That was later downgraded to hooliganism, which carries a maximum sentence of seven years in prison.
In the letter, posted on McCartney's official website, the musician cited his long association with Russia, including an outdoor concert in Red Square in 2003. On that occasion, Putin gave McCartney a personally guided tour of the Kremlin.
McCartney told Putin he hoped they would meet again, "when our schedules allow."
He said Greenpeace, which stages direct-action protests against alleged environmental offenders around the world, was nonviolent and "most certainly not an anti-Russian organization.
"I understand of course that the Russian courts and the Russian presidency are separate," McCartney wrote. "Nevertheless I wonder if you may be able to use whatever influence you have to reunite the detainees with their families?"
An outspoken vegetarian, McCartney has long supported environmental causes, and he has opposed drilling for oil in the Arctic.
He also was one of several international celebrities who last year urged Russia to free two members of punk protest group Pussy Riot. They remain in jail.