There are a few good reasons for it.
- More aerodynamic, we humans don't put out much power so every little bit helps
- Padded shorts. You want these for anything longer than a short ride. Most shorts with pads happen to be spandex.
- Moisture wicking
- (debatable?) Read some things a few years ago about muscle fatigue when jiggling (rough road/mountain biking) is greater than if you can compress the muscles a bit so they don't move as much