Why do jet engine fan blades have a twisted shape?
Your question is about fan blade twist, but actually the answer is valid for nearly all rotating blades. If a blade weren't twisted, the angle of attack would be very different from its root to its tip.
Twist equalizes the angle of attack along the length. I say equalize for simplification, the angle may not be designed to be equal, other aspects may requires the blade to include some variation of the angle of attack, e.g. to prevent the blade to oscillate (flutter), still the general goal is a to equalize the angle.
Angle of attack
The angle of attack is the angle between airflow and blade chord.

For the blade to be efficient this angle must be close to the maximum lift angle, which is roughly around 15° for usual airfoils:

However we're talking about the direction air actually comes from, as seen by the blade. When the aircraft is moving straight and level, for the pilot air comes from ahead, but this is not true for the fan blade, due to blade rotation.
Velocity created by rotation (tangential velocity) depends whether the point is close to the center of rotation (smaller velocity), or close to the tip (larger velocity).

For a rotating blade, air direction is the (vector) sum of aircraft translation, which is aircraft airspeed, and blade rotation. The sum has a fixed component, the translation, and a variable component, the tangential velocity at the point under consideration:

Let's imagine we have tweaked the blade angle of attack at location A. What happens at locations B and C if the blade is not twisted?

As we move closer to the blade tip, the tangential speed increases relatively to forward speed, so the sum (purple) gets more vertical. Angle of attack is now too small for locations B, and in C it is even negative, that is the blade pushes air in the wrong direction.
To offset air direction rotation as we get closer to the tip, the blade must be twisted by a value shown in gray in the picture above. Near the root where forward motion is the largest, the chord is close to the direction of travel; near the tip where tangential speed is the largest, the chord is nearly in the plane of rotation of the fan:

Source: The excellent Bjorn’s corner
Effect of twist: Varying incidence
The angle of attack of the blades at the tip is lower than at the hub because it is moving at a higher velocity than the hub
From what was discussed we are able to distinguish the actual angle of attack from the apparent angle, which is generally called pitch or incidence, that is the angle between the engine longitudinal axis and the chord.
On a twisted blade, incidence varies, and is larger at blade tip. However the angle of attack, which actually depends on rotational velocity and cannot be evaluated visually, should be more or less constant.
Fan blade specificity in turbofans
In turbofans, the fan acts on two separate flows: Primary flow, the smaller in mass which is used to produce gas to spin the turbine; and secondary flow, the largest which bypasses the engine core and propels the aircraft.
Accordingly, fan blades in such engines are designed in two sections. Near the hub, blades are part of the low pressure compressor, their role is to increase pressure. Elsewhere they accelerate air a bit to create thrust, like a propeller.
These two designs must deal with their own constraints and optimizations, this gives a particular shape. Modern fan blades are formed hollow sandwiches titanium/aluminum and composites, and are comparatively lighter and more complex. When rotating they are less stressed, in particular where velocity is higher, than heavier blades, and they can be wider without being subject to deformation. This allows to give them a more optimized shape, including twist, taper, dihedral, sweep, etc. The shape evolution over time is visible in the last picture of this answer.