The 29-year-old is the newly promoted side's first signing of the summer.
Fredericks joined West Ham from Fulham, where he played with Bournemouth boss Scott Parker, in 2018, and made 77 appearances in total for the Hammers.
However, Fredericks made just seven appearances in the Premier League last term as he struggled for a regular starting berth.
'I'm happy to get it over line and I can't wait to get the season started,' the full back told Bournemouth's website.
'The manager got in touch and was the first person I spoke to. I've had offers from various clubs but the manager was the one who showed the most interest in me, and the club in general, and really sold it well to me.
'It's been amazing the type of player he was. He's installed that hard work ethic into the club and obviously the quality.
'The games I have watched over the past couple of seasons they have pretty much dominated and played a really nice style of football and I'm not surprised the impact he has had at the club.'
Bournemouth chief executive Neill Blake added: "To be able to sign a player of Ryan's ability and experience on a free transfer is a coup."
"I know Scott speaks very highly of his professionalism and character and he's a talented player that will bolster the squad."
Bournemouth are back in the Premier League after a two-year absence and will host Aston Villa in their first game of the 2022/2023 season.