Some of these 3D optical illusion GIFs are really really good. Scrat—the saber-tooth squirrel from Ice Age—really achieves the effect. It's perhaps the best of this collection.
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.