The phrase doesn't mean literally traveling far, but trying very hard. He said he'd go to the ends of the earth to find the perfect gift.
Pro Tip 2/3
Emotional Intensity
It's used to express deep commitment or strong emotions for someone or something. Parents often say they would go to the ends of the earth for their children.
Pro Tip 3/3
Not Literal
This idiom is hyperbolic, meaning it exaggerates to make a point. She would go to the ends of the earth to see her favorite band play live.