The decision to bunt, manager Don Mattingly said, was Yelich's decision.
"I don't think he feels great right now," Mattingly said. "I think that's an indication of him wanting to do the job for the team. Get that guy over there. That's definitely on his own. It's not really what I want, but I understand what he was doing."
Martin Prado was on second with no outs, with Giancarlo Stanton on deck in a two-run game against reliever Enrique Burgos.
As the showdown continued, instead of playing for a run, Yelich delivered the decisive blow of the night.
Statcast™ projected the home run at 420 feet from the plate, with an exit velocity of 108 mph.
The insurance made for a less stressful ninth inning for closer A.J. Ramos, who completed Miami's second shutout of the season.
"It's nice, especially with where we're at," Mattingly said. "Where we're at [bullpen] availability-wise, and where we're at with [the D-backs'] lineup. I've seen these guys enough to know they're a dangerous club. Right now, they're down a little bit, but they're a dangerous club. They can swing the bats. You don't want to let them get rolling."