It was Jesus who appeared to Hagar, comforted her, and gave her the promise of future blessings. It was Jesus who came to her when it seemed everything and everyone else had let her down.
He has wandered away into the darkness of his doubting, got lost in his grief, confused by the pains he’s suffered. It happens. Shepherds sometimes become lost sheep as well.
I came across a "deep commentary" in the form of a Facebook meme, extolling the frustrations of the natural man's inability to understand the things of God.