Reviewer makes an obvious and serious mistake and paper is rejected
It is pretty normal for a reviewer not to get the gist of your article and then the article gets rejected. I find that the best way to deal with that is to remember that the reviewers are reading the article more carefully than the future readers. So if they don't get what I want to write, the future readers are surely not going to get what I want to write. 

Sometimes reviewers are just wrong: they are humans too and typically do this with a limited time budget (a larger time budget than future readers will want to spent on your article, but still pretty small). That is bad luck. Just improve what needs improving and submit your article to the next journal.