The illusion makes use of two devices to suggest distance - the perspective lines receding to a vanishing point and the use of shading. Because these features cause the eye to think that the darkest elephant is nearer, we assume it will appear largest. The fact that the lightest shade of elephant appears larger fools us into thinking it is actually a bigger elephant.
This illusion is from a very old newspaper cutting though the same illusion (or variants on it) appears in popular publications today. The caption invites the reader to guess which elephant is bigger...but this is an illusion: They are all the same size. If you don't believe it, try measuring them with a ruler.