Answer :
One theory as to why Siam managed to remain independent throughout the 19th century is because its geographic location allowed it to be a sort of buffer zone between two competing powers namely the British and the French.
Siam (Thailand) never cooperated nor entered into any conflict with France or England, instead Thailand would conveniently play the British against the French and vice versa.
If either of these two powers began to invade the land, the other country was promptly informed and would stop the guilty party. Since none of them wanted conflict, they would move outside Thailand's borders.