Kyrgios, who defeated second-ranked Novak Djokovic in straight sets to advance to the quarters, tweeted that he was unable to play and believed it could be due to food poisoning.
Neither Kyrgios nor Federer had dropped serve in the tournament. Their only other meeting was decided in three tiebreakers -- including 12-10 in the third set -- at Madrid in 2015.
"I was really looking forward to playing the match," Federer told fans waiting for the match on stadium court. "It's a pity."
Scrambling to find something for fans to watch, tournament officials trotted out tournament director-player Tommy Haas and Vasek Pospisil for an exhibition. Pospisil upset top-ranked Andy Murray in the second round before losing to Dusan Lajovic in his next match.
This is the fourth time Kyrgios has withdrawn from a match before it was played. He did so twice in 2016, dropping out in the third round of the US Open with a hip injury and exiting before a Dubai semifinal because of back problems.
The result ends an auspicious run at Indian Wells for Kyrgios, who was coming off his second win of the year against Djokovic. After that match, Kyrgios spoke of the mental improvements in his game and his resolve to keep growing.
After a disappointing Australian Open in January, Kyrgios turned his season around, highlighted by a win against Djokovic en route to the Acapulco semifinals.
"Every time I go on the practice court, I try and be positive, try and have fun, not being too hard on myself," Kyrgios told reporters. "I was in a pretty dark place."
"He's the greatest player of all time," Kyrgios said of Federer on Wednesday. "Age is just a thing for him. As long as he stays healthy, he's going to be the top player, you know, around that top tier."
After the withdrawal, Federer moved into the semifinals at Indian Wells for the 10th time in his career. He defeated Rafael Nadal in straight sets Wednesday to reach the quarterfinals.
"I'm playing great tennis, and I didn't expect it because I'm still on the comeback," said Federer, who won his record 18th Grand Slam title at the Australian Open in January after being sidelined by various injuries for much of 2016.
The Swiss star sent get-well wishes to Kyrgios on Friday.
Jack Sock will face Federer in the next round.
The Associated Press contributed to this report.