Let me be a bit more detailed.
GIF uses the LZW compression algorithm, an algorithm which enables one to
produce a complete replica of the original data. To do this, the software
finds certain recurring bit patterns in the original data. For each pattern
it finds, it assigns it an identifier that is shorter than the data it
represents. Then, every time that particular pattern appears in the data,
it is replaced with that identifier. In the GIF file is a table listing the
identifiers and the patterns they replace so the reader can reconstruct the
original example.
As a somewhat contrived example, imagine that you are writing a paper on,
say, the Spanish Inquisition. You have a computer on which you can do all
the edits and revisions, but you don't have access to a printer or removable
storage, so you are forced to submit a handwritten copy. Since writing
things out by hand takes time, you decide to assign certain codes to certain
words that appear quite often in the text. For example, every instance of
"Torquemada" is assigned "A1", every instance of "ideology" is assigned
"A2", every instance of "the" is assigned A3, and so on. So the paper you
give to your professor is a sequence of codes that required much less
writing than writing out the entire thing would have been, and attached is a
table correlating each code to the word it represents. All your professor
has to do, then, is go through this table and replace each code with its
associated word, after which he is free to corner the market on red ink.
LZW (which GIF uses) is ideal, then, for simple line-art pictures because
such images are likely to contain several repeating patterns of data--for
example, a large plain white background with a regular area of green or
purple inside, perhaps with a sequence of red-purple-orange-blue-red
occurring several times as well. This doesn't work so well with photographs
which, by their very nature, generally do not have many repeating patterns
within. As a result, GIF would almost certainly not produce any significant
improvement in file size on a photograph (and in fact would probably be
larger than the original data because of the metadata overhead). Instead,
photographs are generally distributed in the JPEG format, which essentially
"smears" similar pixels in an area together to reduce the amount of data
necessary. While this would probably not have an adverse affect on the
types of images for which GIF is typically used, GIF generally produces
better compression ratios on simple images than JPEG does.