The phrase first appeared in print in the 'Boston Journal' in 1884, meaning any form of excitement or situations where people were very loud and clearly enjoying themselves. I suppose it was based on the fact that red is generally seen as a cheerful - even fiery - colour. Painting the town thus, metaphorically speaking, made it a brighter, 'louder' place.
i was always told that painting the town red comes from the "red light district" or the shady part of town and when you "paint the town red" you are in a sense turning the whole town into the red light district.