The cy pres doctrine arose so far back in antiquity that its origins are obscure. Apparently it was known and used in Roman law, for an application of the cy pres doctrine is reported in the Digest of Justinian. In the early part of the third century a city received a legacy bequeathed for the purpose of commemorating the memory of the donor by using the income of the legacy to hold yearly games. As such games were illegal at that time a problem arose concerning the disposition of the legacy. Modestinus, a well known jurist, found the solution.
Edith L. Fisch,
THE CY PRES DOCTRINE AND CHANGING PHILOSOPHIES,
Mich. L. Rev.
Available at: https://repository.law.umich.edu/mlr/vol51/iss3/4