The magi were agents of Herod, whether three or not is unknown.
They came to worship Christ; Herod tried to point them to another mission and they refused.
“They returned home by another route.”