...And are determined by a number of factors
Including the flight's direction, turbulence, and flight duration. For example, there's “the cardinal direction altitude rule.” This stipulates that commercial airliners traveling Northeast, East, Southeast, and one degree short of South fly at odd altitudes (31,000ft, 33,000ft, etc.), while those traveling all other directions fly at even thousands (32,000, 34,000ft, etc.).
Clear-air turbulence (CAT) affects altitude, as well. Pilots report any turbulence they encounter, and Air Traffic Control (ATC) uses that information to steer other planes above or below it.
Finally, longer flights benefit from flying at higher altitudes; the thinner air reduces drag, increases engine efficiency, and saves fuel.
Airline dispatchers calculate the ideal altitude for every flight
Airline dispatchers are employed by carriers, and generally work in the company’s HQ. They control the planning and execution of their airline’s flights -- keeping track of where they are, where they are going, their fuel/weight, as well as assigning them specific routes. Most importantly, they calculate a flight’s ideal altitude and request it from Air Traffic Control, who tries to accommodate the request when giving the pilot clearance to take off.