Why do modern bicycles have curved front wheel forks?

For the bicycle to handle well, it needs a certain trail - an offset between the point where the wheel touches the ground, and the point where the line through the steerer tube (axis of steering) touches the ground. If this distance is too large, the bike is hard to turn; if it's too small (or negative), it becomes unstable.

In principle it is possible to choose an angle of the steerer tube that gives the right offset with a straight fork; but if you do so, you will have a very uncomfortable ride as the fork will have very little compliance along its length. If you angle the steering axis, vertical displacements (bumps in the road) can be absorbed by bending of the fork. This is more comfortable.

But once you have the steering axis at an angle, you need to do something to get the right trailing distance. This is done by offsetting the axis of the wheel relative to the steering axis. There are two mechanisms for doing this. The first is to weld an offset plate to the straight fork. This is the method used in mountain bikes. It is robust, but expensive. Because there are very significant stresses at such junctions, it requires a lot of material. This makes a mountain bike fork relatively heavy. The second is to use a curve. This prevents the formation of stress concentration (no sudden angles). And because the stress is distributed, the fork can be tapered - thinner near the wheel, where the bending moment is smaller. This saves material (cost, weight) without compromising safety or comfort.

This picture may help:

enter image description here

UPDATE

Bikes with carbon forks tend to have "straight" forks (much easier manufacturing with carbon fiber), but they are angled to get the same effect. See for example this annotated image of a random carbon fiber bike - original from centrecitycycles.com:

enter image description here