The British monarch said the “frightening” experience of cancer could also illuminate the “best of humanity” as he thanked medical workers and charities.