Carpets absorb the sound and doesn't allow it to bounce/reflect off of surface.
This is done to make sure there is no reverb effect in the studio or the auditorium.
Otherwise, the music would sound more like noise with all that sound reflecting off of the hard and uncovered surface.
musicfans.stackexchange.com/users/1589/Bipolar Metalhead
Practically, it offers a few things: For drummers : A place to keep your drums in relatively one place.
The louder the drummer, the worse they move and shimmy around.
Having a carpet/thick rug the feet can dig into helps with this movement.
For other performers : I always appreciated a rug underneath me as a guitarist (or any performer, really) because it softened the blow to my feet of standing for hours at a time in (relatively) one place.
Sound Absorption.
It does help with reflection and bass response, as noted in other answers.
Aesthetically, it offers something much more important:
Everybody does it .
Country, Blues, Rock, Jazz, Metal.
I've seen it nearly at every show where it's appropriate.
Kinda like "Check 1, 2.
Check.
Check." to test out the mics.
musicfans.stackexchange.com/users/None/
Greg Lake, of Emerson Lake and Palmer, had a carpet onstage to compensate for his fairly simple bass rig.
Emerson and Palmer had far more complex rigs, so Lake's carpet was his own ostentatious touch onstage.
I imagine this has been copied elsewhere.
More practically a carpet will reduce footstep noise from telegraphing up microphone stands.
musicfans.stackexchange.com/users/1889/ABragg
If you use effect pedals and try to press them with your foot, sometimes they tend to slip away from their position.
Using a carpent prevents them from doing so.
A carpet gives you a non slippery surface to put your stuff on.
musicfans.stackexchange.com/users/1353/papakias
I think there's a good reason for that: ground issues.
Prevents electrocution if something fails.
With a carpet making a layer, your feet never really touch and connects with the ground.
Probably this came from a time when equipment had more problems with ground.
But with security, even today, it's never enough.
You and your pedals are in a protective layer.
You need to understand and read more, because, for example, there was a time I was playing bass guitar in a poor place without ground (illegal, house without license to be built), off course, an illegal electrical installation, and when I touch the wall...
I felt the current flowing.
Was not big deal...
but it could be bad.
So, rubber shoes are ok, never touch anything, wall etc.
Carefull with the mics, make sure about ground in the equipment.
But there are many reasons above, like protect the equipment from touching a bad floor, reverb issues, cleaning issues and others also wich
I'm not sure, but I won't discard.
Stay safe!
musicfans.stackexchange.com/users/6763/Rúben Couto
Lots of musicians used them so that they would have the same surface at every tour stop, there are some pretty gnarly venue floors out on the road which ends up wearing down on feet.
Especially with all the hallucinogens present in the 60s and 70s
it was probably really comforting having the same surface everywhere you played.
musicfans.stackexchange.com/users/4206/Justus Bradshaw
I oftenly see rock or metal bands playing on carpets while performing on stage or on studio.  It's nice to see, but is there a reason for these carpets? Is it for a better sound?  For an example,  here's Foo Fighters live on studio ON carpets.
Why do musicians play on carpets?
musicfans.stackexchange.com
<bands><concert>
musicfans.stackexchange.com/questions/3395
musicfans.stackexchange.com/users/2149/Sushi
Carpets absorb sound and provide a non-slip surface to put your stuff on that is also soft and more resistant in case of an electrical fault. Many musicians would bring one on tour to ensure a suitable surface everywhere they went. The reasons as of why bands use carpets during live performances are to insure sound absorption, to prevent slipping and electrocution. However, it is also thought to be a way to ensure having the same surface at every venue. 
Carpets are used for sound absorption Carpets are used to prevent slipping  Carpets are used to prevent electrocution To ensure they have the same surface to play on, musicians use carpets at venues.