The Kingdom of Siam probably used a simple red banner as its first flag, back in the late 1600's.
Then, later, to represent the Chakri Dynasty, a white Chakra was added to the centre of the banner. The chakra was the weapon of the god Vishnu.
Then, in 1820, an elephant was added to the inside of the chakra. This is significant, since in Thailand, the elephant is a very important symbol of the nation.
Then, in 1855, King Rama VI decided that the plain red banner as the civil ensign was not distinct enough for international relations, so he added a white elephant. This flag became known as Thong Chang. The elephant flag.
Then, in 1893, the elephant had royal regalia added to it.
Legend has it that during a flood, King Rama VI spotted his flag being flown upside down. And in order to prevent this happening again, in 1917, he created a new flag. This time, with no symbols, just including 2 white stripes set away from the top and bottom of the flag. In essence, the same as the flag of today, but the central stripe remained red.
Then later in 1917, the central red stripe was replaced with a deep blue shade. There are a couple of theories behind the blue. 1 is that blue was regarded as an auspicious colour for Saturday, the day on which the king was born. Another idea is that it was to show solidarity with the allied nations during WWI. Britain, France, the US. All of which have red, white, and blue in their flags.
The three colours now stand for Nation, Religion, King. The unofficial motto for Thailand.