Check this article about “How to get permanent residency in Thailand“. Be aware that it is a very long process.
If a foreigner has permanent residency in Thailand, he doesn’t have to do visas at immigration anymore, neither the famous 90 days notice. There are also other benefits but permanent residency is NOT citizenship. That means you still require to have a work permit if you work in Thailand and you also can’t buy land (unless you are a rare exceptions like a BOI approval or others).