1. It happens due to resonance. When a vehicle is driven, the piston of the engine makes in and out motion at a frequency depending upon its speed. The vibrations caused by the movement of piston are transmitted to all parts of the vehicle. It is just possible that some parts of the vehicle (or its frame), may have natural frequency of to and fro movement of piston at the certain speed of the vehicle. When this happens, then at this particular speed of the vehicle that part starts vibrating vigorously due to resonance.
2. To stop the rattling sound. The speed of vehicle is changed, so that the condition of resonance will not then hold.