Simply put, Du Fu lived in the transitional period from the prosperous Tang Dynasty to the late Tang Dynasty. In his heyday, an Shi rebellion broke out. During this period, the society was in turmoil, the political situation was dark and the people were displaced. So Du Fu's poems reflected the social contradictions and people's sufferings at that time. For example, "Li Shihao" wrote that when Du Fu was in Shihao Village (when the Anshi Rebellion broke out), he arrested evil officials, exposed the cruelty of officials and reflected the sufferings of the people.
Don't forget that Du Fu's poetry is called "the history of poetry" because it describes the current affairs and politics and the broad social life picture before and after the An Shi Rebellion.
Du Fu is a realistic poet, contrary to Li Bai's romanticism. Some people say that Li Bai is as bold and unrestrained as the choppy Yellow River, and Du Fu is as calm and vigorous as the majestic and beautiful Mount Tai.
By comparison, it is not difficult to know that Du Fu's style is "depressed and frustrated". This is related to the society at that time.