Because of stress
Geckos drop their tails when they are put under stress. Excessive heat can be a cause for stress for a gecko.
Because it got bullied
Sometimes geckos drop their tails because they are getting bullied by other geckos or pets in the same tank or space.
Its tail got grabbed
When a gecko gets its tail grabbed or pinched, it usually drops it as a defense mechanism.
Illness causes it
Illness can cause the gecko to drop its tail because its sense react differently when it’ss ill.
It could be infected
Similar to its reaction to illness, a gecko tends to drop its tail when it is infected in a way or another. (See Why are Zoos important?)
It’s a defense mechanism
Dropping the tail is an automated defense mechanism that the gecko uses when it is in danger or being attacked.
Some geckos can grow new tails
Some breeds of geckos have the ability to generate a new tail. While the tail might not be the same, it can function just as well as the original. However, some geckos do not have that ability, yet they adjust and adapt to being without one. It could take up to a few days for them to adjust.
To lure away danger
As a defense mechanism, geckos can drop their tails which would continue to twitch as they escape the danger. (See How many Animals are there in the World?)