In the episode "Moe Goes from Rags to Riches" the rag explains how it became a rag over the years:
1012 A.D.: Tapestry made by a peasant wife and what it showed was what the tapestry would experience over the years.
Dark Ages: Stolen by Vikings and swindled to arabs.
1200's: Part of a tent owned by a young Persian king (Nelson) this story was a parody of 1001 Arabian nights.
1400's: Rag used for torture and used by Michelangelo.
1800's: Used to make a Confederate flag
1930's: Rag in rag soup during the depression.
1962: Used as a flag during a Mt. Everest expedition and found by a yeti and presented it to his son (Moe).
Now he's used like a toy for Santa's Little Helper.