They came, I think, from a 19th century affection for playful prints and pictures for the parlour. An early form of light entertainment for middle-class Europeans, I guess (well they didn't have Eastenders or Wii). But of course, the trend was not confined to our neck of the woods. The far east had its own versions too. Here's a fantastically colourful post from Pink Tentacle:
'Joge-e, or “two-way pictures,” are a type of woodblock print that can be viewed either rightside-up or upside-down. Large numbers of these playful prints were produced for mass consumption in the 19th century, and they commonly featured bizarre faces of deities, monsters or historical figures (including some from China). Only a few examples of original joge-e survive today. Here are a few.
'This print by Kuniyoshi (c. 1852) depicts Hotei (Laughing Buddha) and Shoki (a character from the “Romance of the Three Kingdoms“). When viewed upside-down, Hotei becomes Asahina (a character from a popular novel of the time) and Shoki becomes Zhang Fei.
'This woodblock print was published by Ezakiya Tatsuzo (c. 1842). Left to right, top to bottom (upside-down image described in parentheses): 1. Small tengu (Gedo, an evil person), 2. King Zhou, Shang Dynasty (Guan Yu), 3. Wind god (Thunder), 4. Nyudo (Pair of frogs), 5. Tengu looking up (Tengu looking down), 6. Tofu Kozo (Mitsume Kozo), 7. Onamuchi-no-mikoto, Shinto god of nation-building, farming, business and medicine (Iruka-no-omi), 8. Cao Cao (Shoki, Zhang Fei), 9. Mikenja (Ghost of Mirin).
'This print by Kuniyoshi (c. 1852) shows a Daruma and Tokusakari (a character from a famous Noh play). Viewed upside-down, the Daruma becomes a Gedo (an evil person) and Tokusakari becomes Ikyu (a character from the famous play “Sukeroku”).
'Created by Yoshitora, 1861. Left column (top to bottom): 1. Fukusuke, god of merchant prosperity (Frog), 2. Evil man (Ebisu, god of fishermen and good luck), 3. Fukurokuju, god of wisdom and longevity (Tanuki, racoon dog with giant scrotum). Center: 4. Ikyu (Foreigner) , 5. Okame (Dekusuke), 6. Gedo, an evil person (Asahina). Right: 7. Hotei, Laughing Buddha (Yakko), 8. Earth god (Mountain god).
'Created by Yoshitora, 1862. Left column (top to bottom): 1. Tadafumi (Gedo, an evil person), 2. Hunter (Frog), 3. Small tengu (Big tengu), 4. Bad guy (Bad guy). Center: 5. Two-horned demon (One-horned demon), 6. Kasane, possessed female character in famous Kabuki play (Ugly man), 7. Daruma (Daruma). Right: 8. Foreigner (Ainu), 9. Nio guardian (A-un guardian).
[Images from: Edo no Asobi-e, Tokyo Shoseki, 1988 (out of print)]'