The Mongols have a long history of raiding China. Given how rich and powerful China was, why did they not simply conquer Mongolia?
The short version: They did "simply" conquer Mongolia, at least three times (depending on exactly what counts as "conquer"). These were the conquests by the Han, the Tang, and the Qing. Control of the region by the Han and Tang was lost during their major mid-dynasty civil wars/rebellions, which almost destroyed the dynasties. The Qing maintained control until their fall.
The longer version:
As early as the Han Dynasty, China was fighting for control of Mongolia. These wars, often called the Han-Xiongnu War(s), at the end of the 2nd century BC and early 1st century BC, left the Han as the masters of Mongolia. Rather than garrisoning and directly ruling Mongolia, local Xiongnu rulers continued to rule, as Han vassals.
These wars highlight some of the difficulties faced by China in trying to conquer Mongolia:
Chinese armies were typically dependent on supply lines connecting them to China. This made them vulnerable to having their supply lines cut, and made invasions of Mongolia expensive. This dependence also applied to any large garrisons that the Chinese might leave in Mongolia - they would be expensive, and vulnerable to siege.
Chinese armies were often slow, and had trouble trying to force a decisive battle.
While the general population of Mongolian peoples could not move as fast as Mongolian armies, being limited to the speed their herds could move at, they were still more mobile than farming peoples. This allowed them to avoid Chinese armies.
A key to success by Chinese armies was sufficiently strong cavalry. This was expensive, and was also dependent on trade with the steppe.
We can summarise these by saying that, for the Chinese, conquering Mongolia and far from simple, and a realistic attempt to do so would be very expensive. If it failed, military and monetary losses could be very high, for no gain. Conquest was not always the best option. Peaceful relations would minimise raiding by Mongolian peoples, provide access to horses from the steppe for the Chinese army through trade, and allow Chinese merchants to profit from Chinese-Mongolian trade.
Han control over Mongolia, particularly the area that in now the country of Mongolia (i.e., "Outer Mongolia") was eroded by civil war in the mid-Han (the transition from the Western Han to the Eastern Han).
A map showing the main Han Dynasty invasions of Mongolia:
Later, the Tang Dynasty conquered Mongolia, with their defeat of, first, the Eastern Göktürks, and, second, the Xuyantuo. This area was then ruled by a Tang military government (The Protectorate General to Pacify the North). Tang control was strong only from 647 to 687, when the growth of the Second Göktürk Khaganate presented them with a rival, and decades of war and raiding. 721 saw peace between the Tang and the Second Göktürk Khaganate, with the latter as Tang tributaries and vassals. The collapse of the Khaganate in the 740s, and its replacement by the Uyghur Khaganate, led to a new player aiming at conquering the Mongolian steppe. With the general collapse of Tang power during the An Lushan Rebellion (755-763), the Tang lost control of the area to the Uyghur Khaganate. The Uyghurs provided military assistance to the Tang to help their recovery from the An Lushan Rebellion, and maintained generally friendly relations with the Tang.
The Tang protectorates:
The Uyghur Khaganate:
Finally, the Qing conquered Mongolia during the 17th and 18th century. Their conquest and control was aided by the use of firearms (cannon and muskets). The Qing maintained this control until their fall in 1911, when Outer Mongolia (i.e., the modern country of Mongolia) declared its independence.
Map of Mongolia under Qing rule:
Well, it is worth stating that there was a time when 'China', for a given definition of 'China', conquered Mongolia, but the way it did so is worth digging into. Fortunately, I did so in this answer a couple years back, but am happy to add clarification on any points if needed.
What that answer doesn't get into, at least not explicitly, is why pre-Qing states failed at maintaining power in the steppe effectively. For that, we need to discuss the 'Nomadic Military Advantage' thesis, which, funnily enough, I also got into, see this answer and this answer.