Say "cheese" is an instruction used by photographers who are having difficulty getting their subject to smile. By saying "cheese", most people form their mouths into what appears to be a smile-like shape. Additionally, the absurdity of saying "cheese" for no apparent reason can incite glee in some people.
As this practice became ingrained into modern society, it has taken on the simple role of a final warning before a photograph is taken. Often subjects will simply use the phrase "say cheese" as a cue to enter their final pose and to smile, neglecting to actually say "cheese".
Over the years, many other words have been used in place of cheese. For comedic effect, a photographer might say "Say ______" filling the blank with a word relevant to the event or action he is photographing. (Ex. "Say wipe out" during a seaside photograph) Other times a person will fill the blank with an absurdist or seemingly entirely random word of their choice.
Perhaps due to strong Western influence, especially in the realm of photography, and perhaps due to increased numbers of Western visitors after photographic equipment became widely available, the phrase "Say Cheese" has also entered into the Japanese language. However, the word "say" is almost always dropped from the phrase, resulting in the phrase simply being "Cheese." This is usually pronounced in Japanese (and written in katakana) as "chiizu" (チーズ).
Other languages have adopted this method, albeit with different words that sound similar to cheese to get the desired effect of shaping the mouth to form a smile.
Author R. L. Stine wrote an adolescent horror book titled Say Cheese and Die, which is about a young boy who finds a camera that shows the people or objects he takes pictures of as skeletons or being involved in tragic incidents. Shortly after the picture is taken the incident portrayed in the photo actually happens.
Comedian Dane Cook does a bit about "Say Cheese" and how it is so arbitrary and meaningless yet pervasive.