One small addition to the above! As altitude increases, air density decreases; this reduces damping, which leads to the decrease in dynamic lateral and directional stability.
A helpful way (if not strictly correct) to think about it is that as an aircraft oscillates laterally, the wings and tailplane move up and down through the air and this creates drag opposing the motion and damping it. If the air is dense (sea level) the drag force is higher, and if the air is thin (hot and/or high conditions) then the drag is lower because there are less gas molecules getting in the way of the motion. With the directional case the tail is moving side to side, as is the fuselage, so this creates side-to-side drag which damps the directional oscillation.