Allegedly Cameron tried, and got an excellent deal, apparently, which basically seemed to change nothing. He said that if he didn't get what he wanted, he would recommend leaving. A lot of people believe he got nothing, not even anything based on his heavily watered-down "demands". Therefore they felt lied to, so voted out to punish him. As Neil says, quite likely a fair number of those people voted without a full understanding of the implications. The remain side clearly didn't manage to promote the value of being in the EU - as with Clinton in the US, the referendum was theirs to lose, and they did so. People should have leant towards the status quo, ought to have been an easy win. They ran a negative campaign, trying to scare people into voting remain and it simply didn't work. Nobody believes politicians any more.
I have seen some quite blinkered views, but also reasoned decisions on both sides of the argument. Personally, I was very much in favour of the common market, still am, but I am very much opposed to the federal EU state as it stands at the moment, or as it wants to become. But nobody seems prepared to move from their respective standpoints, or even attempt to understand the (quite possibly misguided) anger and dissatisfaction that exists in certain parts of the UK. Calling people stupid ain't the way to go, either.

//