The past couple of weeks, I have had the opportunity to discuss the reason why Mormons do not drink alcohol, coffee, tea or smoke or chew tobacco products.
According to Brigham Young:
"The first school of the prophets was held in a small room situated over the Prophet Joseph's kitchen.... When they assembled together in this room after breakfast, the first they did was to light their pipes, and, while smoking, talk about the great things of the kingdom, and spit all over the room, and as soon as the pipe was out of their mouths a large chew of tobacco would then be taken. Often when the Prophet entered the room to give the school instructions he would find himself in a cloud of tobacco smoke. This, and the complaints of his wife at having to clean so filthy a floor, made the Prophet think upon the matter, and he inquired of the Lord relating to the conduct of the Elders in using tobacco, and the revelation known as the Word of Wisdom was the result of his inquiry." - LDS Journal of Discourses, volume 12, page158.
According to this rendition, the "revelation" was in response to the complaints of his wife. Another part of the story that I have read is that Emma was fond of her tea and coffee parties, which is why the "revelation" also banned "strong drinks" which includes tea and coffee.
David Whitmer stated:
“Some of the men were excessive chewers of the filthy weed, and their disgusting slobbering and spitting cause Mrs. Smith... to make the ironical remark that ‘It would be a good thing if a revelation could be had declaring the use of tobacco a sin, and commanding its suppression’' the matter was taken up and joked about, one of the brethren suggested that the revelation should also provide for a total abstinence from tea and coffee drinking, intending this as a counter dig at the sisters. Sure enough the subject was afterward taken up in dead earnest, and the 'Word of Wisdom' was the result ” - David Whitmer quote in Des Moines Daily News, October 16, 1886, page 20.
More information about how the Word of Wisdom was followed in the early days of Mormonism can be found here.