I recall that New Scientist ran an article addressing this issue a while back.
Apparently it doesn't affect everybody in that manner and only people with a particular gene variant (myself included) suffer the runny nose when eating spicy food.
Whatever survival advantage that gene selects for was not, as far as I can recall, determined but a trawl through the archives may find the original article.
Interestingly, the reason that we continue to consume spicy foods despite the obvious discomfort is that the active ingredient, capsaicin, stimulates the release of endorphins, chiefly dopamine, creating a minor 'high' and suppressing aches and pains. It has this effect whether your nose runs or not.
I find that chewing raw ginger root on long (and I mean long) walks suppresses the muscular aches and joint pains that excessive exercise generates in old derelicts like myself. However, the muscles need a day or two to recover and repair themselves afterwards and the capsaicin gets you in the end (if you know which end I mean).