As far as midi is concerned, this message doesn't do anything. It's there for information only. However, some software that seeks to display the information in the midi file will make use of this information, and this may affect how the musical information is displayed.
It is usual to put this item in the first track.
As per the SMF spec, this message comprises 5 bytes.
FF, 59, 02 signify the actual item, and there are two bytes of data.
The first byte of data is in the range -7 to 0 to 7 where a minus # is the number of flats, 0 means it's the key of C, and + numbers are the number of sharps. The second data item is either 0 or 1, where 0 indicates Major, and 1 signifies Minor key.