People who live close to the sea have better mental health than those who live further away, regardless of their household income, a new study suggests.