When to use 'for'' and when not to is a question that definitely concerns many of my students. Here I've shown its usage in the present perfect tense.
It's possible to leave out for ( but not usually in negative sentences):
For example:
They have been married (for) ten years. ( with or without for)
They haven't had a holiday for ten years. ( you must use for)
We do not use for + all ……( all day/ all my life, etc.)
I've lived here all my life. ( not for all my life)