Basic defragmenting, overly simplified...
You write data on a new drive, drive is full:
--------------------------------------------------------------------------------------------|
You start adding and deleting data and soon end up with:
-- - - --- ------ --- - -- --------- ----- ------------------- -- -- --- -- -- ------------ - |
At this point, say you add a large file. As the drive's free space is spread around, your file will have to be split into chunks (ie fragments). The more you split up a file, the more your drive's head will be hopping around to access it. Naturally, this will also slow the drive down. So you've added the large file 'o' and end up with:
--o-o--o-- ----o-- - -- ----------o----o------------------ -- -- --- -- -- ------------ - |
You add a second large file 's':
--o-o--o-- ----o--s--s ----------o----o------------------s--ss---- -- -- ------------ - |
By defragmenting, the software basically copies, regroups, and reorganizes the data to obtain something more like this:
--oooooo---sssss---------------------------------------------------------- |
That's in the perfect world and defragmenting in its most basic form. The defrag tool in Windows won't move any system files and there will still be holes, but individual data will no longer be split in chunks. I'm not familiar with the intricacies, but aside from the above, Windows may also try to reorganize or group files which are frequently accessed closer together, for example, or include other criteria to better optimize the data on the drive.