When you download an MP3 or other type of sound file, you're downloading a bunch of ones and zeroes that are smashed together in a format that tells your computer, iPod, or smartphone to produce an audio signal. While it stands to reason that the more data enclosed within will mean that there's more sound signals that are reproduced, analyzing fidelity is a little more complicated than that.
It's often the case that people who are surprised by how bad their music sounds have downloaded their music either several years ago, or compressed their files to a very tiny size, meaning they do not have a high bit rate. It's often the difference between sounding like it came through a telephone (8kbps or 8,000 bits per second), or at the best available format for commercial music (1,411.2kbps, or 1,411,200 bits per second). While it's the most common file format, MP3s from iTunes or Amazon are actually not technically the best digital audio format that's available to consumers, as their bit rate is commonly 320kbps. These files are termed "lossy" (as opposed to "lossless") because they lack a certain amount of potential audio data.
Some of you may be wondering: "If MP3s aren't the best way to listen to music, then what is?" This is where FLAC or ALAC files come in. If you have any on your computer, you'll notice that the file has a.flac or.alac file extension after the file name. FLAC (Free Lossless Audio Codec) typically has a much higher bit rate than MP3 files, and are therefore prized in the audiophile community. For comparison's sake, better FLAC files can run to about 1,411.2kbps, while most of the music you download from iTunes or Amazon is 320kbps. This also means that there is a huge difference between the file sizes, but the FLAC file has a much higher bit rate, and therefore much higher upside. There are also many other filetypes out there like OGG, mp4 and the like that satisfy different uses like mixing, but for the casual listener, bit rate is what matters. Assuming you have better ears than most people, FLAC files should sound better to you than 320kpbs MP3 files with the right setup.
Keep in mind that for FLAC to fly, you need the hardware and the software to make the most of it: if either is lacking, it won't sound as good as it can. Most audio players will usually tell you what bit rate your music is being played back to you at, but if you're running iTunes, you may run into problems listening to FLAC files. Although you can download utilities that will make it possible, you may just want to download another music player like Foobar2000 that supports it natively. Additionally, without a home setup to take advantage of the higher file quality, you will probably be unable to hear the difference. FLAC files won't sound all that good on mobile devices until better audio hardware becomes more common, despite the presence of apps that unlock the capability of playback showing up online.