it used to be a hardware thing, so if your pixels were represented by a nibble, and the definition of the color for each of the 16 possible value is in table the hardware references, you just update that table (on a vsync, or even an hsync) and you could get cool animations effects (for the time)
random example from the Atari 800xl https://www.youtube.com/watch?v=uPjLZ4MVKCc (you can see how slow it is to draw a scene, but the animation effect due to pallete rotation is really fast).