How do I know whats my null hypothesis? I was reading about t-tests and began wondering why the null hypothesis is chosen such that it states there is no difference between the means.
The deeper question I have here is how do I state my null hypothesis? I could just as well say the null hypothesis is that the means are different.
In the case of means, I know beforehand whats my null hypothesis but in any other case say whether applying a coat of paint on the roof reduces the temperature or not, how do I know what my null hypothesis should be?
Is there a formal way to arrive at the null hypothesis?
 A: It's really the other way around. You choose your null and alternative hypothesis, then derive a statistical test for it. The t-test refers to a series of hypothesis tests that rely on the Student-t distribution. In a first course on statistics these tests are typically:

*

*One sample t-test with $H_0: \mu = 0$ and $H_1: \mu \neq 0$;

*One sample t-test with $H_0: \mu = 0$ and $H_1: \mu > 0$;

*One sample t-test with $H_0: \mu = 0$ and $H_1: \mu < 0$;

*Two sampled t-test with $H_0: \mu_x = \mu_y$ and $H_1: \mu_x \neq \mu_y$;

*etc

*etc

In addition to choosing what to test, you typically need to make some assumptions about the data, such as independence/dependence or perhaps a distributional assumption. In the case of t-tests we are, at a minimum, assuming Normality of the data and that we don't know the true variance and need to estimate it as part of our routine. These assumptions mean that the above tests will result in test statistics that have Student-t distributions, hence the name.
The description on the testing process here does a good job of describing how to think about building up a test from data: https://en.wikipedia.org/wiki/Statistical_hypothesis_testing
A: Just to add to an excellent answer from @fruitmincepie.  Your question reminded me of when I first "got" significance testing some years ago.  The following realisation made it click for me...
The key point (this isn't always strictly true, but it's good for now) is that a null hypothesis is generally a mathematically precise way that things could be.  So, "equal means" is a precise way that things can be, and we can make a mathematical model for what sort of datasets we would get if that were true.  (I'm glossing over @fruitmincepie's important point about not knowing the variance).
So, we know what sort of datasets we would expect to get if it were true.  If our dataset is not one of these, then we start thinking maybe our null was false.  And that is your goal in significance testing: to falsify the null by showing that your dataset contradicts it.
Example: Blancmange Dataset
For example, suppose we choose 10 men and 10 women and measure their love of blancmange.  Now suppose that men and women love blancmange equally (call this our null!).  What sort of datasets might we get?  We would probably get the men and women's blancmange-love scores intermingled, right?  Maybe a few men might come out a bit higher just by luck of the draw?  Or equally a few women might?  But certainly, we wouldn't expect to accidentally pick 10 men who all loved blancmange more than all of 10 women.  At least, not if our null is true that men and women love blancmange equally.  So, when we find that all ten of our men love blancmange more than all ten of our women we seriously doubt our null hypothesis.  And so, probably, men do indeed love blancmange more than women.
Now, imagine trying to model the null, "men and women differ in love of blancmange".  What sort of datasets would you expect to get then?  Pretty much anything, right?  So, you'd have no way of contradicting it, because it is so nebulous, any dataset will probably support it.  (Even one where the men and women come out the same could almost as easily happen by luck of the draw from a world where men and women differ than from one where they don't).
So, "means are equal" is a precise statement, that you can build a mathematical of, to predict what sort of datasets you'd get if it were true.  "Means are not equal" is not -- it is a vague statement, and you could get pretty much any dataset if that were true, and so you're neither able to model it, nor to contradict it.
