Choice of null and alternative hypothesis 
A firm producing tobacco cigarettes claims that it has discovered a new technique for curing tobacco leaves, that results in an average nicotine content of a cigarette of less than 1.5 mg. To test this claim, a sample of 20 of the firm's cigarettes are analyzed. If it were known that the standard deviation of a cigarette's nicotine content was 0.7 mg, what conclusions can be drawn, at the 5% significance level, if the average nicotine content of these 20 cigarettes were 1.42 mg?

According to the text, the null and alternative hypothesis are:
$H_0$:μ≥1.5
$H_a$:μ<1.5
The z statistic is -0.511 and p{Z<=-0.511) = 0.305. Since this exceeds 0.05, $H_0$ is not rejected. That is, we don't reject the claim that the average is >= 1.5. 
What if the firm had claimed that their research resulted in an average of less than or equal to 1.5mg? I've read that the null hypothesis has to contain the equality. So the new hypotheses will be:
$H_0$:μ<=1.5
$H_a$:μ>1.5
The z statistic remains the same P{Z>=0.511) = .695. Thus $H_0$ is again not rejected. So this time, we are not rejecting the claim that the average is less than or equal to 1.5, which is the result that the firm must be hoping for. So what is going on here? Can including a single value in the claim make this bizarre difference? Can't they just pretend that they never carried out the first test, and then just do the second, getting the proof that they're looking for?
 A: As whuber pointed out in the comments, the bizzare jump simply occurred because the definition of which event is the null hypothesis, and which event is the alternative hypothesis - simply switched. By definition, the probabilities of the null hypothesis and alternative hypothesis will sum to 1, so switching them will always change the result from some $x$ to $1 - x$.

This begs the question, though, of why did the events switch. You state in your question:

I've read that the null hypothesis has to contain the equality.

Indeed there are various such guidelines like that, e.g. in this lecture:

If the original claim includes equality (<=, =, or >=), it is the null hypothesis. If the original claim does not include equality (<, not equal, >) then the null hypothesis is the complement of the original claim. The null hypothesis always includes the equal sign. The decision is based on the null hypothesis.

Your question, though, shows why this guideline is sometimes meaningless. Your use of the z-score indicates a use of the normal distribution, for which the probability of attaining a specific value (e.g., 1.5) is 0. It is a completely arbitrary decision whether to calculate the probability of the result being $< 1.5$ or $\leq 1.5$. 

So how to decide which is the null hypothesis here? As the Wikipedia entry states:

The choice of the null hypothesis is associated with sparse and inconsistent advice.

However, it also states the common sense advice:

Routine procedure: Start from the scientific hypothesis. Translate this to a statistical alternative hypothesis and proceed: "Because Ha expresses the effect that we wish to find evidence for, we often begin with Ha and then set up H0 as the statement that the hoped-for effect is not present."[4] This advice is reversed for modeling applications where we hope not to find evidence against the null.

In your particular case, the problem is: 

A firm producing tobacco cigarettes claims that it has discovered a new technique for curing tobacco leaves, that results in an average nicotine content of a cigarette of less than 1.5 mg.

so the first alternative in your question would be the one to choose. If there would be a formalistic objection based on the equality, you could counter that, in this case, it makes no difference which alternative contained the equality.
A: As explained in this answer What follows if we fail to reject the null hypothesis? one can only find 'statistical evidence' for $H_a$ if the sample is such that $H_0$ is rejected.  If $H_0$ can not be rejected then the only conclusion one can draw is that $H_0$ does not lead to a statistical contradiction.
In other words if one can not reject $H_0$ that does not imply that $H_0$ is true, this is the reason why we say that it is ''accepted'' (which is not the same as statistically proven).

In your example, the first hypothesis test $H_0: \mu \le 1.5$ versus
$H_a: \mu > 1.5$ you find a p-value of 0.305 which means that your
sample does not provide ''evidence'' for $H_a$.  This does however
not imply that you can conclude that $H_0$ is true (it is only not rejected or accepted, but there is no evidence for $H_0$.
In your second situation you test $H_0: \mu \le 1.5$ versus
$H_a: \mu > 1.5$ you find a p-value of 0.695, so you have no evidence thet $H_a$ is true.  The fact that you can not prove that $H_a$ holds does not imply that $H_0$ holds.

The only conclusion that you can draw from your example is that your sample does not provide evidence for $H_a: \mu < 1.5$ nor does it provide evidence for $H_a: \mu > 1.5$.
