Diagnosis
The motor brushes are worn out or the armature is dirty. This is a brush motor. The noise is arcing.
How to Fix It
This requires disassembly. Remove the battery. Unscrew the two long housing screws near the base. Separate the clamshell halves. Locate the two carbon brushes in their holders on the motor. Replace both brushes with Ryobi part #RYB311201. Reassemble.
If That Didn't Work
With the housing open, inspect the copper commutator on the armature. If it's black or has deep grooves, the armature is damaged. The whole motor assembly likely needs replacement.
Heads Up
Do not run the motor with severely worn brushes. It will permanently damage the armature. Always replace brushes in pairs.