The other answers describe the process well but here’s my personal perspective on how I got into it:
When cycling off-road, wheel rims would regularly go out of shape so I purchased spoke spanners to correct the side-to-side wobble by adjusting the spoke tension. This was important as back in the 90s as almost all non-professional mountain bikes used some form of rim brake: cantilever, and later, V-brakes. I would fix the wheels by removing the tyre and tube and mounting the wheel in the forks (front wheel) or wheel stays (rear wheel) so I could see where the wobbles were.
I eventually realised that the rims also needed to be trued radially, i.e., the rim forms a perfect circle and is consistently equidistant from the flanges of the hub. I was doing this often enough that I ended up buying a proper truing stand and I became the go-to guy for fixing wheels for friends.
Given enough abuse from mountain-biking, eventually wheels can no longer be trued by adjusting spoke tension. It seemed a shame – and environmentally wrong – to discard a wheel when it had a good-quality hub so I graduated to buying new spokes and rims to build on to the old hub (which would usually last for years) using the instructions from Sheldon Brown (as linked to in a sibling comment).
The process of building a wheel requires an understanding of the physical forces acting on the spokes and rim but the practice is more like an art. The more you did it, the better you got at avoiding issues like residual twist. It’s a bit like tuning a stringed instrument. I would even pluck the spokes and compare the pitch to get a feel for the amount of tension the individual spoke was under. It was very satisfying to get a consistent tone.