I will give you some highly non-technical reason why it sounds correct in some sentences and not others. Mostly it just has to do with the way the brain processes information and not what is grammatically correct.
In very short sentences 'for' becomes a filler word. For most adults short sentences without detail where expected can seem incomplete. (Particularly in the case where a quantity could be reasonably expected.) When faced with what we perceive as an incomplete thought or concept we attempt to search for the missing information. This momentary search is what causes the dissonance when reading these sentences. The inclusion of the preposition 'for' is a momentary break from the flow of the sentence and it signals as hint to our brain that there is no missing information. (Our brain does not need to search for a specific detail on quantity, 'for' indicates there will not any.) To illustrate you can replace 'for' with any abstract concept of quantity that will server the same purpose such as 'many' or or 'most' or 'few' and hear how they still sound correct (although now conveying slightly different meanings).
I suffered years.
I suffered for years.
I suffered many years.
I suffered most years.
We tried years to get pregnant.
We tried for years to get pregnant.
We tried many years to get pregnant.
We tried most years to get pregnant.
The key reason for all of this is trickery going on in our brain is that 'for' acts as a substantive modifier. Without we are momentarily left questioning the concrete existence of the noun being modified, and our brain is left looking for more.
In the OP's original examples the inclusion of specific quantities is exactly the reason why the inclusion of "for" becomes unnecessary.
The reason 'for' works particularly well is that it is a very vague concept of quantity. It also happens to have a unique quality, in that it happens to sound (even when read) like a very specific quantity i.e. "four" the number. In fact in casual conversation you would be forgiven for interpreting it as such.
"I suffered for years."
"Well I hope your fifth year is better."
In longer sentences, "for" functions to bridge the phrase across the entire sentence. The further from the subject the harder the phrase will be to interpret the without some form of phrase modifier. In this case it is functioning to pull the phrase together.
I suffered years.
I suffered for years.
I suffered the slings and arrows of fortune, years.
I suffered the slings and arrows of fortune for years.
"Oh well, only 4 years, that's not too bad."
In fact you will note that on the longer example to get the first phrase to sound even remotely correct it becomes necessary to force the inclusion of a pause. (Try reading it it without the comma.)