Williams, 46, is due to play doubles with her sister Serena at Wimbledon, which starts in a week's time, and was also given a wildcard to enter the Bad Homburg singles.
She took her time to get going against qualifier Irina-Camelia Begu of Romania, losing the opening set 6-2 before battling back to take the second 6-4.
Williams led 5-3 in the decider and was two points from victory at one point but Begu dug in to force a tie-break, which she won 8-6.
Sixth seed Osaka, 28, had little trouble seeing off Pole Magdalena Frech 6-4, 6-1.
The first set was close until a rain-enforced break at 5-4, after which, the four-time Grand Slam champion lost only one more game.
Osaka has never won a grass court tournament, with her best result a semi-final at Nottingham in 2018.
