Over a period of time. the flexing of the floor or expansion and contraction of the timber may loosen the floorboard nails. It is the resulting movement of the wood against the nails or against the neighbouring boards that produces the typical irritating squeak.
The simplest cure is to drive the floorboard nails in deeper with a nail punch, which allows the tapered edges of the nails to grip the wood more securely. However, this may not be a lasting solution. If the problem persists, use either a larger or ring-shank nails. The latter are designed to give a better grip however they need to have clearance holes drilled through the boards. Fill any redundant holes with a matching wood filler.
If the boards can’t be renailed satisfactorily (for example, because of twisting or bowing), use countersunk stainless-steel woodscrews. Bury the heads of the screws deep enough to cover them with filler or with matching wooden plugs. Dampening the wood thoroughly before fixing will help it to ‘give’ as the boards are screwed down.