The FFT computes the coefficients for a periodic, ever repeating signal. In practical applications, signal segments are finite and not periodic. Just applying the FFT to a segment of a signal essentially wraps the end of the segment around to the start, generating a jump discontinuity. Such jumps result in an undesirable background artifacts in the FFT amplitudes. To make the wrap-around smooth, one can fade the signal to zero at both segment ends by multiplying it with a window function.
If the signal is essentially smooth, then even a simple linear fade to zero may not enough, since also kinks in the signal lead to some background artifacts in the amplitudes, however much smaller than those resulting from jumps. The choice of the windowing function is thus a balance between background artifact reduction and computational simplicity, and also of the length of the segment.
Additional considerations are required for overlap-add schemes, where the shifted window functions have to add to one.