Both talk about the future, but they have different uses. 'Going to' is for plans and evidence. 'Will' is for spontaneous decisions and opinions.
Quick tip: Already planned? = going to. See evidence? = going to. Deciding right now? = will. Your opinion? = will.
Going to: plans already decided
Use 'going to' when you already made a decision or plan before now.
I 'm going to visit my parents this weekend. (I planned it.)
She 's going to start a new job. (She signed a contract.)
We 're going to have a party. (We already organized it.)
He 's going to study medicine. (He applied to medical school.)
Going to: evidence you can see
Use 'going to' when you can see something is about to happen.
Look at those clouds! It 's going to rain.
Watch out! That cup 's going to fall!
She looks tired. She 's going to need some rest.
The bus is full. We 're going to have to wait.
Will: spontaneous decisions
Use 'will' when you decide something right now, at the moment of speaking.
The phone is ringing. I 'll answer it.
I'm hungry. I think I 'll order a pizza.
That sounds fun! I 'll join you.
It's hot. I 'll open the window.
Will: opinions, offers, promises
Use 'will' for predictions based on your opinion, or to offer and promise.
I think she 'll like the gift. (opinion)
I 'll help you carry those bags. (offer)
I promise I won't be late. (promise)
I'm sure everything will be fine. (opinion)
Common mistakes
Not "I just decided. I'm going to have the tea." — say "I just decided. I 'll have the tea.". Spontaneous decision = will.
Not "Look at those clouds. It will rain." — say "Look at those clouds. It 's going to rain.". Evidence you can see = going to.
Not "I bought tickets. I'll fly to Spain next week." — say "I bought tickets. I 'm going to fly to Spain next week.". Already planned and arranged = going to.
Practise it
Ask yourself: Did I already decide this? (going to) Or am I deciding right now? (will) Can I see evidence? (going to) Or is it my opinion? (will)