They can put a MIL light on for a variety of reasons. The engine management system received information from a load of different sensors and actuators under the bonnet. It is programmed with information to give the fuel injectors (and sometimes ignition timing) based on this information. It also knows what sort of information if OUGHT to be getting, so if it detects that one of the sensors is reading way outside the range that it ought to, it will ignore what it's being told and just make up a kind of "average" value instead. That sends it into "get-you-home" mode and these days, most of them are so good that you can hardly tell by driving the car. Because of this, it makes a note in its memory of the fault that triggered it and it puts the MIL on. When you take it to a dealer, they'll plug in their fault code reader and see what the fault was. Then they'll (hopefully!) change the right bit and all will be well again. It's very rare to do any real damage driving with it on but manufacturers have to cover their backsides!
On some cars, you can clear a fault code by disconnecting the battery for half an hour. If the fault that triggered the light was only temporary, that could be all that you need (although it's not very likely). BEWARE that disconnecting the battery might also loose any radio code you might have had! Alternatively, many independent garages now have generic fault code readers. They're probably not quite as good as the manufacturer's equipment but many of them seem to work just fine.