Intervals are commonly done on a running track because the set distance gives structure to the workout by allowing you to gauge your pace and provides for comparable results across a given time frame.
For road racers, the distances covered on the track will vary from 200 meters (220 yards) to a mile, with rest periods in between the harder efforts. It is these harder efforts and the rest periods in between that allow for speed gains over time.
The distance covered on the track during a hard effort corresponds to the race you are training for, fitness and experience. Shorter efforts are good for shorter races (and those just staring out on speed work), while longer efforts are good for longer races such as half marathons and marathons.
A 200 meter (220 yards or half lap) work effort is good for racers fine-tuning their speed for a 5k race, while a 400 meter (440 yards or a full lap) work effort is good for improving overall conditioning and improving speed for shorter races.
An 800 meter effort (880 yards or two full laps), is good for increasing speed and strength for shorter races, and can be done in training for longer races to sharpen speed.
Mile repeats are excellent for half-marathon and marathon efforts. Because you will circle the track four times, these efforts can help you judge your pace, and will also improve your aerobic capacity and overall conditioning.
How many and how hard are subjective questions which can be answered by your running experience, current fitness, and running goals. In general, it is best to err on the side of less is more. Be conservative in pacing and leave adequate recovery time between work intervals. Always leave the track feeling tired, but like you could have done more.
With any speed work, remember to warm up with ten minutes of easy running before the hard efforts, and allow for a ten minute easy run at the end as well.