For some consonants there are multiple letters. Originally they represented separate sounds, but over the years the distinction between those sounds was lost and the letters were used instead to indicate tones.
Thai is a tonal language with 5 tones. The tone of a syllable is determined by a combination of the class of consonant, the type of syllable (open or closed), the tone marker and the length of the vowel. More details.
There are no spaces between words, instead spaces in a Thai text indicate the end of a clause or sentence.