Williams had been due to face 18th seed Wang Qiang of China, who defeated Johanna Konta in the second round, on Sunday.
It is the second successive event from which Williams has pulled out, with the 37-year-old having retired during her third-round clash with Garbine Muguruza in Indian Wells a fortnight ago because of illness.
Williams said in a statement: "I am disappointed to withdraw from the Miami Open due to a left knee injury. It was an amazing experience to play at the Hard Rock Stadium this year and I would like to thank the Miami Open for putting on an amazing event.
"I hope to be back next year to play at this one-of-a-kind tournament in front of the incredible fans here in Miami."
While Williams has been impressive at the grand slams since her return following the birth of her daughter, she has made little impression on the WTA Tour, winning just five matches in six tournaments.
Osaka came close to losing to the unconventional Hsieh at the Australian Open but this time she could not finish off the job despite leading by a set and 5-3.
Having failed to serve out the match, Osaka, who trailed 4-1 in the opening set, lost the second on a tie-break and then saw an early break in the third slip away as Hsieh prevailed 4-6 7-6 (4) 6-3.
It was the first time in 64 matches that Osaka had lost a match having won the first set and her record as world number one is now a less than stellar three wins and three defeats.
Osaka could lose top spot in the rankings after this tournament and Petra Kvitova, one of the players in contention to overtake her, battled into the fourth round with a 6-4 3-6 6-4 victory over Donna Vekic.
Ashleigh Barty easily dispatched her fellow Australian Sam Stosur 6-0 6-3 while 19th seed Carolina Garcia was a 6-0 7-5 winner against Julia Goerges.
Caroline Wozniacki booked her place in the fourth round after a tough test against Monica Niculescu.
After an early break, Wozniacki was put under pressure in the closing stages of both the first and second set, but managed to stave off a Niculescu comeback in the tie-breaker to prevail 6-4 7-6 (4).
Seventh seed Kiki Bertens, meanwhile, fought back from a set down to battle past Slovakia's Viktoria Kuzmova 3-6 6-0 6-1.
Indian Wells champion Bianca Andreescu notched up her 10th win in a row, toppling eighth seed and world number four Angelique Kerber.
The 18-year-old Canadian, who became one of the most unexpected champions of recent years when she won the title in the Californian desert, prevailed 6-4 4-6 6-1 to maintain her winning record against top 10 players this year.