A magic number is a sequence of bytes that is used in all files of a certain format, usually at a given position (often at the beginning). Since all files in that particular format have that particular byte sequence in that particular position, and most files in other formats don't have it, the magic number is a way to recognize what format a file is in.
Here, this concept is applied to a filesystem format. For example, an ext2/ext3/ext4 filesystem always has the bytes
0x53 0xEF at positions 1080–1081. A reiserfs filesystem always has
ReIsErFs starting at position 65588 (or
ReIsEr2Fs, etc., in more recent versions). Other filesystems have similar magic numbers. Filesystem tools check for the presence of the magic number (and possibly other clues) to ensure that you haven't accidentally launched them on data that's organized in a format they can't deal with and could damage. If you change the magic number on a filesystem, ordinary tools are likely to refuse to touch it; repair tools might be more clever and treat a bad magic number as just one of the things that could be broken.
file command recognizes files based on their magic numbers. You can run
file -s /dev/sda1 to see what it thinks is on the partition
/dev/sda1. Its decisions are based on a database typically found in
/usr/share/misc/magic. Specific commands may use different magic numbers to recognize the file formats they can cope with.