In an ion trap quantum computer, collective motional modes are used to entangle two or more qubits in order to execute multiqubit logical gates. Any residual entanglement between the internal and motional states of the ions results in loss of fidelity, especially when there are many spectator ions in the crystal. We propose using a frequency-modulated driving force to minimize such errors. In simulation, we obtained an optimized frequency-modulated 2-qubit gate that can suppress errors to less than 0.01% and is robust against frequency drifts over +/- 1 kHz. Experimentally, we have obtained a 2-qubit gate fidelity of 98.3(4)%, a state-of-the-art result for 2-qubit gates with five ions.