He was a court painter who dared to anger his royal patron - an intellectual, wedded to ambiguity, who could show the public mask and the person behind it. Jonathan Jones examines the work of Hans ...