The air just above the fire becomes hotter. This hotter air is optically rarer but the colder air further up is optically denser, so when we see the objects by the light coming from them through hot and cold air layers having different optical densities, then refraction of light takes place randomly due to which the objects appear to be moving slightly.