Electronic Speed Controllers are efficient devices for driving small motors. This is a quick introduction to a typical hobby ESC for brushless motors.
Briefly, the ESC's job is to take your battery power and ration it to your motor based on control signals. The control signals come as PWM (Pulse Width Modulation) from a receiver or intermediate device such as a flight controller. The ESC has a small microcontroller on board that reacts to that frequency, performs a little logic on it, and sends appropriate power to the motor.
Many ESCs also integrate a BEC (Battery Eliminator Circuit). This is essentially a voltage regulator that should maintain a specific stable voltage for powering other devices. Typically it will be 5v, and would be used to power things like your radio receiver, flight controller, LED lights, etc.
ESCs come with motor leads, and some people choose to solder bullet connectors to them and to their motors, making it easy to connect and disconnect. It is probably more common that people will remove the leads that come pre-attached and instead solder the motor leads directly as was done in the top ESC in the above photo. A common issue with doing this is that most cheap ESCs will have huge blobs of solder, making the connection much messier and more difficult than it needs to be. In these cases, I suggest using desoldering braid to remove most or all of the blob and then use a small amount of new solder for making your required connections.
When wiring your motor, the direction of rotation will be controlled by the order or your connections. Typically the motor's power wires will come out in a flat set, and connecting them in that order will result in counter clockwise rotation. For clockwise rotation, simply switch two of the wires.
Most ESCs will have a 3 wire header, even when they don't include BEC functionality. In those cases, I suggest cutting out a portion of the red wire to be sure that no voltage can ever be sent on it. The 3 wires are typically Brown (Ground), Red (Positive Voltage Out), and Yellow (Signal In).
Be sure to check out my article on testing your ESCs with an Arduino!