Why do cheap guitars go out of tune?
Each string moves through a slot in the nut at the top of the fretboard, and if they’re not moving through that slot smoothly, the result is tension on one side or the other. If the strings don’t sit in those grooves along the nut’s front edge as they move down the fretboard, you’ll be out of tune throughout the neck.