Why is 'that' sometimes optional before dependent clauses?

Solution 1:

In both of the examples in which that is optional, the relative pronoun is the object of the embedded clause.

Long books [that] religious people like tend to be Bibles. [Religious people like long books.]

Water tanks [that] fish need are spacious. [Fish need water tanks.]

This is also allowed when the relative pronoun is the object of a preposition or another oblique argument of the embedded clause:

This is the boat I escaped in. [I escaped in this boat.]

In your other examples, the relative pronoun is the subject of the embedded clause:

Those that are rotten must be thrown away. [Those are rotten.]

Cars that break down endanger pedestrians. [Cars break down.]

English only allows you to omit that when it has been moved from a non-subject position in the embedded clause, and when it's followed by the subject of the embedded clause. I suspect that the reason for this is the ease of comprehension on the part of the listener. A sentence like Cars break down endanger pedestrians, if it were grammatical, would be extremely hard to parse.