I think the origin is simply that humans regard the other as exotic, and project all sorts of fantasies on them that would seem inappropriate to apply to the in-group. The genie was probably a Magical Negro. As I understand it, in Japan, the African man has some sexual initiatory role in their fiction because of the wow factor after WWII. The Magical Negro, Orphan Annie, and many others are just ways people from perceived higher classes exoticize and romanticize people of perceived lower classes.