The story is an addition and expansion of the account of the Biblical Magi, recounted in the Gospel of Matthew in the New Testament.
Like them, he sets out to see the newborn ruler, carrying treasures to give as gifts to the child - a sapphire, a ruby, and a "pearl of great price".
Because he missed the caravan, and he can't cross the desert with only a horse, he is forced to sell one of his treasures in order to buy the camels and supplies necessary for the trip.
He then commences his journey but arrives in Bethlehem too late to see the child, whose parents have fled to Egypt.
He is then struck in the head by a falling roof tile and is about to die, having failed in his quest to find Jesus, but having done much good through charitable works.