When I first heard this advice, I was about to graduate college with a Bachelor's degree. It was from an email "forward" which claimed that it was given by Kurt Vonnegut in a commencement speech. I recently discovered that, in fact, it was a Chicago Tribune newspaper column by Mary Schmich---the graduation speech she'd give if she were ever invited to give one. Wikipedia provides full details about "Wear Sunscreen".
I enjoyed this pho-graduate-speech and thought that it contained excellent advice. At the time, I didn't think seriously about the "wear sunscreen" advice---I'm fair skinned and it seemed essential for avoiding burns even though I sometimes ignored the advice of my parents to apply it liberally and regularly. But, more recently, I've wondered whether "wear sunscreen" is really such great advice. Sunscreen blocks UVB rays which are used by the body to produce Vitamin D. About a year ago, I learned that I am Vitamin D deficient and could use more, not less, UVB rays. Furthermore, sunscreen interacts with skin in ways that may increase the chances of skin cancer; and, sunscreen only partially blocks UVA rays which penetrate more deeply than UVB and have more potential to damage skin cells. These concerns are well-documented in the Wikipedia article on the potential health risks of sunscreen. One fact I did not know about is that increased sunscreen usage is positively correlated with skin cancer rates. Sunscreen is effective at preventing sunburn, but there is no evidence that sunscreen prevents skin cancer. If anything, evidence points in the opposite direction, that using sunscreen increases your chances of getting skin cancer. See, for example, Could Sunscreens Increase Melanoma Risk? and Beneficial Effects of Sun Exposure on Cancer Mortality.
As usual, it seems that the best approach here is moderation. Wearing sunscreen may be dangerous, but repeated severe sunburns are definitely dangerous (if not extremely uncomfortable). Some sun exposure when the sun angle is large enough to provide significant UVB (only in spring/summer around noon in Boston) is greatly beneficial. But, so much that it causes burns is undesirable. It seems that the best approach is to get a small amount of sun as many days as possible, but limit the amount of time you spend in direct sunlight each day. In cases where you know you are going to be in the sun for extended periods of time, the best approach may be to use a full-spectrum sunblock which minimizes the amount of UVA, UVB and infrared light which reaches your skin.