Immigration apart, I think doing something sounded more appealing than doing nothing and the Brexit campaign had more vocal and probably charismatic people supporting that "something". Also, #Brexit is a catchier hastag than #Remain.
The remain campaign was poor. Failed to portrait any positive image of the EU and it was government led, an unpopular one, which didn't help. People looked at it as the establishment.
I think David Cameron will go down as the UK's worst ever Prime Minister, as in the long term he will have caused the most damage to the UK.