The first temple to Confucius was built on this site shortly after his death. It was not until the Han dynasty, however, that the temple was sanctioned by the state. Virtually every dynasty since has paid to maintain or even expand the temple complex.
Information from OrientalArchitecture.com
Information from Wikipedia
I suppose that given recent Chinese history it is fortunate that the temple is still standing. However, it is looking pretty shabby in places, or it was in 2004. The grounds in particular are rather sad looking. The buildings themselves are adequately maintained, at least the important ones. One can't help but imagine how a time-traveler from the middle of Ming dynasty might feel about the shape things are in now.