When film was king, grain was a side effect of the film process. Silver halide crystals were the film's photographic medium. The finer the crystals on the film, the finer would the appearance of grain in the negative. (For simplicity here, we leave aside variables such as under- or over-exposure, or which chemicals were used in processing.) Conversely, the coarser the crystals, the grainier the negative would appear and, thus, the grainier the print.
Electronics advances rapidly, though, and soon digital photography began beating film at the grain/noise game. Consumer digicams, while improved, continued to have significant noise at ISO 400. However, more expensive digital SLRs, featuring larger sensor chips containing larger pixels, began to produce photographs at ISO 400 that contained much less noise than the comparative grain in a film exposure made at ISO 400. Soon ISO 800 became usable, then 1600. Very good digital cameras not only allowed photographers to make "clean" photos at high ISOs, when shot at lower ISOs such as 200 and 100, the digital cameras produced exposures that were virtually noise-free, the equivalent of what a film photographer from past decades might expect at ISO 25 or 50.
Then, as they say, "a funny thing happened," particularly with black and white photographers. It had become quick and easy to convert a color digital photo to black and white, but to the eyes of many photographers, the photos looked too smooth. They lacked a certain character that had been synonymous with black and white. The solution? Just as software could be used to convert a color original to black and white, software could be used to add the appearance of grain. Many photo editing programs include this feature, and some (including one wonderfully named Grain Surgery) exist solely to perform that task.
Future generations may look back on the business of adding grain to photos as a obsolete, quaint activity that was part of the transition from film to digital. Or, rather than universally adopting a smooth look in photographs, they might decide that grain affects texture and, to some eyes, the illusion of sharpness in a photograph.
Below, two versions of the same photo, the first as-shot, the second one with grain added. What do you think?