The 28-year-old, who has also played for Charlton Athletic, has two Republic of Ireland caps and played all but one of the Blues' games in the past two seasons.
"My initial reaction to joining West Ham is excitement," said Randolph. "It was a tough decision turning down Birmingham's offer of a new contract because of the second part of the season we had and the team we had built.
"They are a great group of lads and staff but I felt like I couldn't turn down the chance of joining a club like West Ham. Everybody wants to try and get to the top of their profession and I'm no different."