Primer adheres the paint onto the surface you are painting.
It is needed when you are painting a bare surface like metal, plastic, carbon fiber, etc. Without primer, your paint will not hold or last. If your repair calls for a filler then you will need to apply primer before applying the paint.
If you are unsure whether you need it you are better off using it. Adding primer when it is not needed will not affect your finish.