Why do some military aircraft use variable-sweep wings?
By sweeping wing backwards, you essentially make the air 'see' another airfoil.
Look at these two diagrams:


When the air meets the wing, it travels along $V$. This 'seen' airfoil is a lot thinner than $V1$ (which is perpendicular to the leading edge).  As the aircraft experiences less pressure, the aircraft experiences less drag. However, this also reduces the velocity of the air. This is good if you're looking to delay things such as shockwaves as the air goes supersonic, since spreading the force out more delays this effect and the flow separation which comes with it.

Unfortunately, for all the advantages, It would have a very high landing speed. So the wings are swept forward, the aircraft has a more effective aerofoil for lower speeds, and the minimum airspeed decreases correspondingly. There is now more drag, but also more lift which you need for the slower speed.

Wikipedia puts this nicely in not all too-complex terms:

If we were to begin to slide the wing sideways (spanwise), the sideways motion of the wing relative to the air would be added to the previously perpendicular airflow, resulting in an airflow over the wing at an angle to the leading edge. This angle results in airflow traveling a greater distance from leading edge to trailing edge, and thus the air pressure is distributed over a greater distance (and consequently lessened at any particular point on the surface).
This scenario is identical to the airflow experienced by a swept wing as it travels through the air. The airflow over a swept wing encounters the wing at an angle. That angle can be broken down into two vectors, one perpendicular to the wing, and one parallel to the wing. The flow parallel to the wing has no effect on it, and since the perpendicular vector is shorter (meaning slower) than the actual airflow, it consequently exerts less pressure on the wing. In other words, the wing experiences airflow that is slower - and at lower pressures - than the actual speed of the aircraft. One of the factors that must be taken into account when designing a high-speed wing is compressibility, which is the effect that acts upon a wing as it approaches and passes through the speed of sound. The significant negative effects of compressibility made it a prime issue with aeronautical engineers. Sweep theory helps mitigate the effects of compressibility in transonic and supersonic aircraft because of the reduced pressures. This allows the mach number of an aircraft to be higher than that actually experienced by the wing.

Is there a performance gain? Depends on your definition:
Having fixed swept wings would imply that:

The landing speed might be unacceptably high, and with that, long runways would be required.
You could design a fast and light aircraft.Take the F104 Starfighter for example, which had thin, short wings for the same effect but couldn't move them, and was extremely dangerous at slow speeds.

Having variable wings:

The F14 was intended for carrier operations, where you would want a
slow landing speed. Making an aircraft go that fast would probably have been impossible otherwise. It was also designed for long range operations, adding weight of fuel.
Adds weight and mechanical complexity to the airframe, which increases maintenance cost and fuel burn.

If I understand it correctly, today aircraft today rely more on system such as high-lift devices like for instance slats and flaps.