The battery door has been removed for clarity, but is not necessary. See this guide for how to remove it.
Unscrew the eight Phillips #00 screws on the back panel:
Two 2.5x6mm screws above the screen.
One 3x6mm screw on the upper part of each side (two total; right side shown).
One 3x7.5mm screw on the lower part of each side (two total).
Two 3x4.5mm screws on the bottom.
Pull the back panel up, then tilt it back. There will be two cables still holding it on.
Doing this will also release the connector cover on the left side. Set it aside for now, but remember to reinstall it later.
Disconnect the ribbon cable by flipping the black tab up, then pulling the cable out.
This procedure also applies to all of the other ribbon cables in the D5000.
Pull out the other connector by lifting it up with tweezers, or by prying it out. Fingernails also work well.
The speaker is mounted to the underside of the back panel. There is a a metal shield that holds it on.
Remove the four Phillips #00 screws securing the shield:
Three silver 3x4mm screws.
One black 3x3mm screw.
Remove the shield.
With the shield off, the navigation buttons and "Lv" button are free to move and rotate. Check alignment before replacement.
Lift the blue tape on the ribbon cable.
Desolder the two leads to the speaker.
Pry the speaker out of its cavity.