Hard to Be a God

On another planet going through its Middle Ages, a group of historians from a more advanced Earth live masquerading as commoners.