The resistor is there to limit the current.
Each type/colour of LED has a "forward voltage drop". The rest of your supply voltage is dropped across the series resistor. The voltage across the resistor combined with the resistor value gives you the current. Without it, the LED would burn out because it would pass far too much current.
Since the LED and resistor are in series, it doesn't matter which side it is on.
A red led would be say 2.0V forward voltage. If you use a 5V supply, this means 3V across your resistor. If its a 1k ohm resistor, 3 / 1000 = 3mA current
Blue/White LEDs are usually ~3V so you need different resistor values for the same brightness/current.