Some of these 3D optical illusion GIFs are really really good. Scrat—the sabre-toothed squirrel from Ice Age—achieves the effect the best, in my opinion. Take a look at the full collection below.
These GIFs use depth of field and graphic elements to achieve their effect, just like many classic paintings. The white lines define the plane where the screen is, creating a mental division between background, midplane and foreground. Combined with the camera's depth of field blur, it tricks our brain into thinking that things are popping out of the screen.
The illusion breaks when the object touches the edge of the GIF, which is why the GIFs above work better than the ones below.