ohms is the unit of measurement for resistance

without getting "into" it you need resistance in your ciruits to add load, without it (or too little of it) and you have a lovely smoke generator with optional fire

on the arduino each pin has an absolute max of 40ma and if we go over that (actually near it is pretty bad too) we have a very good chance of burning out that pin. how do we know what is safe ... Ohms law

Ohms law is a fairly simple algebraic equation that can be mixed and matched to find out all sorts of things, in this case we have 2 known values, the voltage the arduino lets out, and the resistance of a speaker, we need to find out how much amperage this is going to draw so we dont go killing our chip (or anything else in its path)

I = V / R
or
0.625 = 5 / 8

woah! 625ma is defiantly too much so we have to add more resistance, but how much? instead of 40 im going to be safe and use 20 so, we want 0.02 amps at the 5 volts the arduino pushes out

R = V / I
or
250 = 5.00 / 0.02

if you now plop 250 into the first equation it should work out to 0.02 amps, which is happy for an arduino even if there was nothing else in between the pin and ground except this resistor

now take the ohms of your speaker and subtract it from 250 and you will have the correct resistor value, if you dont have one of the exact value (as you almost always wont) just choose the one you have closest to the value (preferably bigger in value)

for example
250 ohms + 8 ohm speaker
220-240 ohms + 16 ohm speaker
100 ohms + 150 ohm speaker

would all equal 20ma (+ or - a few microamps) at 5 volts