How does light focused through a lens create bokeh (blurry background)? This question is relevant, though I don't think it quite answers the question.
From a photography perspective, when you open the aperture wide (with a small f-number) you get a very shallow depth of field. Everything outside that narrow field of view shows up blurry. Like this pineapple is crisp and clear, but the grass in front and behind are out of focus.

From a physics perspective, what I (think I) understand is that the image is formed by a photon bouncing off the pineapple, entering the lens, bouncing around a bit, and finally reaching a pixel on the sensor. What I'm confused about is the blurry parts. Surely you can't change the size of the photon... can you?
 A: The problem is that images aren't formed by one ray of light, they're formed by countless rays of light!
A "bundle" of light from the sun ("bundle" meaning a ray localized in space but containing many many photons) will hit the surface of a blade of grass, and all the photons will disperse in a diffuse manner in every direction.
So a bundle of light hits a point on the blade of grass and a sphere (or, a half-sphere) of light expands from this point. Imagine that expanding more, and more, until some chunk of that sphere passes through the aperture of the camera. 
It's then the job of the lens to take that light (which is hitting the entire surface of the lens at all different angles) and focus it down onto a point on whatever photosensitive surface is inside the camera!
But you can't just magically change the direction of a ray of light, you have to do it by mere mortal means, in the form of a slab of glass. Even simple lenses act in a way that's rather complicated. (All the formulas on the wikipedia page on lenses use something called the paraxial approximation, and aren't 'exact', which is why there are so many exceptions to the equations)
Basically, the answer is that this glass lens which changes the direction of rays of light through mere mortal means, will only focus rays to a point on the photosensitive surface if the rays all originate from a specific distance.
I drew some pictures for this on a different post I made on google+. Imagine the leftmost green line is the blade of grass, the middle green line is the lens, and the photosensitive surface is somewhere to the right. In this first case, the subject is too close and a bundle of light hitting the blade of grass will spread out over the whole photosensitive surface (blurry).
Animated version of the following image

In this case, the blade of grass is far enough away. If you put your photosensitive surface to the right of the lens, where all the rays converge, then your subject would be in-focus. If you put it anywhere else, it would be out of focus and slightly blurry!!!
Animated version of the following image

