The 32-year-old made 42 appearances for the Hammers between 2015 and 2017, before moving to Boro in a £5m deal.
He rejoins the London Stadium side on a three-and-a-half-year contract.
"I had no hesitation in coming back," Randolph said.
"This opportunity was simply too good to turn down.
"I'm delighted to be back at West Ham United. I had two great years at the Club previously and still have a lot of friends here, so I had no hesitation in coming back. West Ham is a massive club, with fantastic supporters and an excellent squad of players.
“It's a great challenge for me and I am really looking forward to working with the goalkeepers here and helping the team in any way I can.
“I'd like to thank everyone at Middlesbrough – the management, staff, players and fans – for their support. I had a great time there and wish them all the very best for the rest of the season.
“This opportunity was simply too good to turn down, though. It's a great feeling to be back in the Premier League with such a fantastic club, and I can't wait to get started."