The internal combustion engine is a very clever piece of kit. Once it's started the four-stroke cycle perpetuates itself – the combustion stroke of the cycle begins the induction stroke, and so on – so once it's started, as long as it receives air and fuel is will effectively run indefinitely without any assistance.
But it needs to be started in the first place - which is where the starter motor comes into play! To turn the engine you need a very powerful electric motor. Which is exactly what the starter motor is.
But how does the starter motor work? It's actually relatively simple - as you turn the key it energizes the solenoid on top of the starter motor.
The solenoid connects the electrical connections within the starter to actually turn the electric motor, plus it pushes a rod, which actuates an engaging fork which in turn pushes a pinion gear (connected to the motor) to engage with the flywheel.
The pinion gear then turns the flywheel and the engine starts. As soon as the engine starts (and you let go of the ignition key) the solenoid allows the pinion gear to retract and disengage from the flywheel, preventing damage to the starter.
If you've ever accidentally turned the key with the engine already started you'll have heard a nasty metal-against-metal sound. This is where the pinion gear attempts, and fails to mesh with a rapidly spinning flywheel.
The starter demands a huge amount of power (more than any other component on your car) which is why the symptom of a low battery is always highlighted by difficult starting.