I tried many solutions from this thread, (Deleting some plist files, killing Intel apps, using 3rd party equalizer....) but none of them helped.
But I think I figured out the exact cause of the problem. (at least on my machine).
You can try this to see if it will resolve the problem for you:
Open Activity Monitor, go to Memory Tab and check memory pressure graph. If it's in amber color, then you will most likely experience crackling sound from your speakers.
If you kill enough apps to bring memory pressure graph back to green, then speakers will work flawlessly.
I guess WindowServer process has some memory leak because the longer the laptop stays turned on, its memory usage keeps growing and growing. It can reach even 4-5 GB.
Once you logout and login or restart the computer, WindowServer usage drops to only 500MB. That's why restarting computer fixes the speakers issue for few hours.
Other processes also might be the culprit. Xcode for example uses ~6GB of memory. If your computer configuration has only 16GB memory then there is not much you can do in killing unnecessary apps. I now regret not buying 32GB configuration. But nevertheless, I hope apple somehow addresses this issue.