Travis Shaw added a three-run homer for the Brewers, while Zach Davies (2-2) pitched six innings of four-hit ball. Ryan Braun had two hits, walked twice and drove in a run.
Matt Albers, Dan Jennings and Jeremy Jeffress combined for three scoreless innings of relief.
Salvador Perez homered for Kansas City in his return from the disabled list, and Alex Gordon doubled and scored in his return from the DL, giving the slumping Royals their only offense.
Ian Kennedy (1-3) left after allowing four runs over three shaky innings. He took a liner off his ankle in the third but finished the inning before leaving the game.
Cain walked and scored in the third and fifth before going deep off Burch Smith in the seventh. He also made a couple of nifty grabs in center field, that familiar patch of turf he presided over for seven seasons, and where he helped the Royals to two American League pennants and a World Series title.
Cain parlayed that success into an $80 million, five-year contract in free agency, returning to the club that drafted him in 2004 and eventually traded him to Kansas City in a deal for Zack Greinke.
He was certainly remembered fondly by the Royals faithful.
Cain got his first standing ovation when he sprinted onto the field for warmups, then got another one when he stepped to bat in the first inning. And when he lined his third homer of the year to right to lead off the seventh, the crowd gave him another round of applause.
Kennedy allowed six hits and a walk. He also failed to record a strikeout for the first time in 273 appearances, the second-longest active streak in the majors.
He had precautionary X-rays taken on his right foot that came back negative.