Yes, the light level makes a difference. In fact, it's probably the single most important factor for hostile mob spawning.
Hostile mobs won't spawn in any area that is above light level 7. Torches produce a light level of 14, and that light level decreases by one for every block (along an axis) out. Therefore, any place that is more than 7 blocks away from a torch could spawn a hostile mob. There are other methods of discouraging hostile mobs from spawning, but keeping a well lit area is key.
Update for 1.8 and after
Update 1.8 added a 1/16 meter high hitbox to carpets, which made natural mob spawning on carpets impossible. Carpets are now safe.
Thanks @TomášZato for bringing this up!
(There still are some types of "unnatural" spawning that are able to force mobs into carpets, like Village Sieges.)
Before 1.8
Carpet both does not prevent and does not facilitate mob spawning, but it does help in a way.
Carpet is a non-solid block, so, in terms of algorithm, mobs do not spawn on carpets, but rather in. Basically, you can replace all carpets with signs for the same, but more obvious, situation.
Mob spawning alrotihm, simplified, is the following:
- Pick a totally random place (in 3D, not only on the surface) to spawn a pack. It must be a block of air (not carpet).
- Try to spawn several mobs around the pack on the same height. Block underneath must be solid, and the block mob spawn in may be any non-solid block, like a carpet.
What it means regarding carpets: if you have a level floor in a room, and room is surrounded by solid stone, no mobs will spawn even in the dark, as there are no air blocks on floor level. If you have a building surrounded by air, though, mobs will be able to start spawning outside and "leak" onto your carpet floors.
So, glass floors are as safe as they ever were.
Detailed algorithm is on the wiki.
Best Answer
According to Minecraft Wiki, hostile mobs have a chance of spawning every 1/20th of a second.
But they have to spawn within 128 blocks of the nearest player.
There also needs to be a light level of 7 or less for hostile mobs to spawn.
However, there is also a cap on how many of a single mob can be spawned in an eligible spawning area.