What is the function of a skew sensor in an aircraft?
Skew is essentially when the flap doesn't extend or retract straight back.
Picture a situation where you have a 1 meter wide board you're pushing down a track that's slightly wider than the board.  Your left hand is about a quarter of the way in from the left edge, and your right hand similarly in from the right edge.  As long as you push straight down the track, evenly, with both hands, the board slides along and doesn't contact the edge.  Now suppose that your right hand pushes harder than your left hand: the board will start to turn, and the edges of the board will contact the edges of the track.
The skew sensor detects that this sort of misalignment is starting to happen, and causes the flap drive to stop.  Ideally, this takes place before the flap makes physical contact with any other hardware, so nothing is damaged!
Edit:
Video of flaps being extended &amp; retracted on the ground.  You can see that there are multiple flaps on each wing, and while normally everything moves in synch, you can envision how if one actuator stopped working, the errant flap could get turned pretty far out of alignment, make contact with other hardware, and cause some significant damage.  So before this happens, the skew sensor sends the command back to stop everything from moving.
From Boeing's Aero Magazine:

The 757-300 has incorporated a flap skew detection system. Flap skew occurs when either the inboard or outboard edge of the flap moves farther than the rest of the flap. The flap skew detection system monitors, detects, and shuts down the flaps if a skew condition occurs. The heart of this system is the flap slat accessory module (FSAM), taking the place of the flap slat electronic unit (FSEU) number 3. The new LRU was introduced because the existing configuration of the FSEU would not accommodate the addition of the flap skew circuits.
The flap skew sensors are mounted on the trailing edge of the flap jack screws (fig. 4a). The sensor (fig. 4b) is fixed to the flap track, and a target (which contains magnets) is mounted to the jackscrews. As the jackscrew begins to turn, the target also turns. This will pulse the sensor, and a signal (distance traveled) is sent to the FSAM, which compares this signal with the opposite side of the same flap. If the distances traveled by either side of the flap differ by a predetermined amount, the FSAM will shut down the flap system to help eliminate damage to the flap and surrounding structure and the possible loss of a flap in flight. The alternate flap mode will override the normal flap skew detection function, allowing maintenance personnel to move the flaps after maintenance has been performed. Maintenance personnel must verify the flap fault and also ensure that moving the flap will not cause any damage.