Follow Up Question: this is a bit strange for me: If I stick a wire into my outlet and attach something to the end it will receive charge without completing a loop. Can you explain further?
I certainly hope you are not sticking wires into your outlets! You should be using properly rated cables. That last word is key; cables have more that one wire in them. Mains power cables usually have 2 or 3. For AC mains those are called (in the US at least) hot and neutral, with ground being the optional 3rd one.
See how there’s two metal prongs on one end and two holes on the other? Those are connected to two separate wires in the cable. Just like there’s two wires going to the LED board, every electrical appliance in your house has two wires going from the plug to it. They’re just bound into one cable for convenience.
Why 40mA max?
Experience. Most indicator LEDs are pretty interchangeable since they are used for the same applications. Maybe if you had the datasheet for it you’d see that it can handle 50 mA or something, but 40 is a pretty safe bet.
Why do I need a resistor?
The short answer is because that’s just how LEDs work. Every component acts differently (that’s why there are so many different kinds anyway), and LEDs (and diodes in general) are just not the kind of component you can apply a voltage to and get good results.
The long answer is because the relationship of current to voltage in a diode is not linear like a resistor, but exponential. I don’t just mean “it increases really quickly” like the slang meaning of exponential, it is literally an exponential function like y = ex.
As you can see, above a certain voltage the current shoots up very rapidly. This makes it extremely difficult to control a diode using just a voltage source, because small changes in voltage can cause huge changes in current. The graph’s values are also sensitive to the diode’s temperature. As the junction heats up, the current will actually increase. Depending on how the diode is used in the circuit, this can cause a situation called thermal runaway, where the increasing temperature causes increased current, which causes an even higher temperature in a positive reinforcement loop until the diode is destroyed from overheating or overcurrent.
To combat this, an external circuit is usually used to tame the LED’s current. For low power indicators, a series resistor is usually enough. For higher wattage LEDs, the power dissipated in the resistor becomes substantial, so they tend to be used with more complicated active circuitry (transistors and amplifiers) that can be more precise about regulating the current.