Why we use 330 ohm resistor to connect a LED?
This is to limit current through LED, without resistor LED will eat current until it melts.

Voltage drop across a LED depends on a it's color, for blue led for example - 3.4V.
So if you have 5V power supply, and want 5mA current through led (5mA usually gives good visibility), you need (5V-3.4V)/0.005A = 320 Ohm resistor. (I.e. this resistance will give voltage drop across resistor of 1.6V, remaining 3.4V drops on LED => 5V total)

Red LEDs usually have smaller voltage drop (~2V), so you'll have slightly higher current with same resistor, but anything below 20mA is usually ok. Also, slightly smaller currents are ok, LEDs at 1mA are easily visible.

PS. few extra things:

1) Light output of led is linearly proportional to current until it's well over specifications. That's why everyone are talking about current through led. 

2) Personally I throw 220 Ohm in 5V circuits to make it really bright :-) 

But on my recent project where I had 3.3V supply, and leds of different color (green, red, blue) I had to calculate resistances more carefully, and they were 68 Ohm for blue and 220 Ohm for green and red.