Before a computer storage device such as a hard disk can be used, it needs to be formatted. Basically, this divides it up into many tiny areas. When the operating system saves a file to the storage device, it uses as many of these tiny areas as it needs and, for a large file, this may mean hundreds or even thousands of them. A special area of the storage device is used to keep a record of which of these tiny areas contain the file's data.
Now, when you next need to read the file, the operating system interrogates this reserved area to see where the file is stored, retrieves the data from the various tiny areas and then stitches the file back together in memory.
So far, so good.
Now, let's say you delete the file because you no longer need it. What many people don't realise is that the tiny areas which contain the data of the file you're deleting don't get wiped - they just get flagged as empty in the reserved area. This is how undelete utilities work.
Next time you come to save a file, it can use some of these tiny areas flagged as empty, but may need many more of them because the second file is much bigger than the one which has just been deleted. This means that, over time, the files stored on the storage device are not held in adjacent (or "contiguous", to use the parlance) tiny areas. This can lead to a degradation in performance because the mechanism which reads the data off the storage device needs to jump all over the place to find the individual bits of the file it's trying to retrieve.
Defragmenting is intended to correct this and, as its name suggests, rearranges files so that they are stored in contiguous tiny areas of the disk, thereby giving the retrieval mechanism less work to do.
That's the theory, anyway! It's valid for certain types of formatting only. The vast majority of computers which run Windows use NTFS formatting of their hard disks. Fragmentation is built into the NTFS technology. You can run your defrag utility as often as you like - as soon as it finishes, the disk will fragment again, so you may as well not bother.