At the most basic level, electric motors exist to convert electrical energy into mechanical energy. This is done by way of two interacting magnetic fields -- one stationary, and another attached to a part that can move. A number of types of electric motors exist, but most BEAMbots use DC motors1 in some form or another. DC motors have the potential for very high torque capabilities (although this is generally a function of the physical size of the motor), are easy to miniaturize, and can be "throttled" via adjusting their supply voltage. DC motors are also not only the simplest, but the oldest electric motors.
The basic principles of electromagnetic induction were discovered in the early 1800's by Oersted, Gauss, and Faraday. By 1820, Hans Christian Oersted and Andre Marie Ampere had discovered that an electric current produces a magnetic field. The next 15 years saw a flurry of cross-Atlantic experimentation and innovation, leading finally to a simple DC rotary motor. A number of men were involved in the work, so proper credit for the first DC motor is really a function of just how broadly you choose to define the word "motor."
Fabled experimenter Michael Faraday decided to confirm or refute a number of speculations surrounding Oersted's and Ampere's results. Faraday set to work devising an experiment to demonstrate whether or not a current-carrying wire produced a circular magnetic field around it, and in October of 1821 succeeded in demonstrating this.
Faraday took a dish of mercury and placed a fixed magnet in the middle; above this, he dangled a freely moving wire (the free end of the wire was long enough to dip into the mercury). When he connected a battery to form a circuit, the current-carrying wire circled around the magnet. Faraday then reversed the setup, this time with a fixed wire and a dangling magnet -- again the free part circled around the fixed part. This was the first demonstration of the conversion of electrical energy into motion, and as a result, Faraday is often credited with the invention of the electric motor. Bear in mind, though, that Faraday's electric motor is really just a lab demonstration, as you can't harness it for useful work.
Also note that if you plan on repeating this experiment yourself, you should use salt water (or some similar nontoxic but conductive liquid) for the fluid, rather than mercury. Mercury can be very hazardous to your health, and requires stringent precautions on its use.
It took ten years, but by the summer of 1831 Joseph Henry had improved on Faraday's experimental motor. Henry built a simple device whose moving part was a straight electromagnet rocking on a horizontal axis. Its polarity was reversed automatically by its motion as pairs of wires projecting from its ends made connections alternately with two electrochemical cells. Two vertical permanent magnets alternately attracted and repelled the ends of the electromagnet, making it rock back and forth at 75 cycles per minute.
Henry considered his little machine to be merely a "philosophical toy," but nevertheless believed it was important as the first demonstration of continuous motion produced by magnetic attraction and repulsion. While being more mechanically useful than Faraday's motor, and being the first real use of electromagnets in a motor, it was still by and large a lab experiment.
Just a year after Henry's motor was demonstrated, William Sturgeon invented the commutator, and with it the first rotary electric motor -- in many ways a rotary analogue of Henry's oscillating motor. Sturgeon's motor, while still simple, was the first to provide continuous rotary motion and contained essentially all the elements of a modern DC motor. Note that Sturgeon used horseshoe electromagnets to produce both the moving and stationary magnetic fields (to be specific, he built a shunt wound DC motor).