World No.4 Federer was dominant in the opening set but was pushed in the second before he wrapped up the 6-1 7-5 in one hour and 17 minutes.
"The last time I played her I lost, so anything's a bonus", Osaka said, adding that she felt a few butterflies before opening the first title defense of her career. "After that things went better for me", added the Serbian, who dominated the second set to book a third-round meeting with German Philipp Kohlschreiber, a 6-4, 6-4 victor over Australian Nick Kyrgios.
The seven-time major champion upset the third seed and Australian Open runner-up, winning 4-6, 7-5, 6-4.
"Today I just fought and tried my hardest", said Williams, now ranked 36th in the world.
McHale won her match 6-4, 3-6, 6-4 against Anastasia Pavlyuchenkova.
An outstanding break point saw Djokovic respond for 5-5 before Fratangelo grabbed the lead in the tie-break.
In action for the first time since winning the Australian Open, Djokovic claimed a 7-6 (7-5) 6-2 victory over Fratangelo.
Akash Ambani-Shloka Mehta wedding ceremony
After the guests relish some delicacies, they will witness the last stage of Akash Ambani and Shloka Mehta's wedding . Right from the invitation card to the pre-wedding bash in Switzerland, everything has been so exquisite so far.
Kyrgios had captured his first ATP title in more than a year when he lifted the Mexico Open trophy, beating three top-10 players along the way in world number two Rafael Nadal, No. 9 John Isner of the United States and, in the final, third-ranked German Alexander Zverev. "Novak said he is pain-free and I knew he would return to his best, although it did surprise me how quickly he managed to do that". The victory makes it two straight over Kvitova, as she also downed the Czech in their most recent meeting at the 2017 US Open.
The 24-year-old will face Belinda Bencic in the third round on Monday after the Swiss cruised to a 6-4 6-1 win earlier in the day.
"I let her play her better game, so it's my fault, anyway. We always play three-setters, and suddenly, we have been there again and playing until the end, and in the end of the match, she definitely played better than me", she said of Williams.
Elsewhere on Saturday, fifth-seeded Karolina Pliskova shook off a slow start to defeat Japanese qualifier Misaki Doi 6-7 (4/7), 6-1, 6-1. Then at the start of the year, I had a little strain on my thigh and I could not play in Brisbane.
Nishikori next faces 67th-ranked Hubert Hurkacz of Poland, who defeated France's Lucas Pouille 6-2, 3-6, 6-4.
Britain's 22nd seed Kyle Edmund advanced to round three with a 6-2 6-0 victory over Chile's Nicolas Jarry.