Where does the word meme come from?

The idea of a social 'meme' comes from the scientist Richard Dawkins.
 In the The Selfish Gene (1976) Dawkins argues that ideas evolve by a process of natural selection.
Just as genes propagate themselves in the gene pool by leaping from body to body via sperms or eggs, so memes propagate themselves in the meme pool by leaping from brain to brain.
Thought some have challenged the notion that an idea can 'leap' from 'brain to brain' this usage of meme has seeped into general English. This is perhaps an indication of the the application of Darwinism to non-biological areas.

Cultural Memes

Here BBC Radio 4's Start the Week discuss the idea of  a 'cultural meme':

What is an internet meme?

The term internet meme strays some distance from the Dawkins' definition. It has become shorthand to describe something that quickly becomes popular online. Examples of internet memes include the Harlem Shake and the phrase FAIL.

fail – v., n., adj.a youthful expression to summarise a bad situation or experience.

Most internet memes are ephemeral and quickly pass into obscurity. A few have endured - Rickrolling from 2007, for example. This suggests an online natural selection, of sorts.