From what I understand the Chinese and Persians have maintained relations since the Parthian timed and trade occurred but war never really happened other than the battle of talas. What are the reasons for this ? It would make sense that the two of the world powers would eventually clash. As a follow up question, why has Persia never tried to invade China or vis versa ? My hunch is that it has to do with the Himalayas and the steppe tribes of the north as natural barriers but I would like to know a more informed opinion. Thanks.
TL:DR It would be really, really, hard and not in the best interests of either group to do so.
Looking at this map of the First Persian Empire during its height and contrasting it with this map of China in the 3rd century BCE, we see that "China" and Persia weren't necessarily neighbors. The Chinese borders of today were hardly the borders of China then, and even so China was not the homogeneous body we think of it as today; Chinese history is filled with so much infighting, civil wars and clashes between different cultures it's disingenuous to look at it as the history of a single nation state.
Even if the land in between were controlled by comparatively easy conquerable peoples (it wasn't), we can see that mobilizing an army into that area would be pretty difficult. Let's assume Persia (being a singular imperial body) would be the invasive army in this war. The Himalayas between the modern Chinese border and the Middle East is about the size of Germany and significantly more difficult to transport an army through than when Hannibal went through the Alps. Even if they get past the mountains an army would to go through the Tibetan Plateau which is notably non-arable land. Why does this matter? Well, if you're marching an army 6000Km (and that's if you go in a strait line), you are going to need to feed them, and without canning or refrigeration your only options are to stock up and hope the food wont go bad after months on end (and not require more horses than your usual campaigns through the fertile crecent (which you would also need to feed)), or live of the land of your enemy, who we've established live a lot farther from the Persian Empire than the modern Chinese border.
Okay, well, why around them to the north?
While you might not go through the mountains, you have just increased the length of your trip through deserts, steppes and exacerbated the aforementioned food problem - not to mention all of this assumes you have dressed your soldiers for the different climates they stand to encounter on this march/have the resources to dress them as you march. All the while you have raiders on central Asian steppes who will have no problem making your life hell as they raid your camps, pick off your scouts and turn tail the moment you waist resources trying to go after them.
So can't go through the mountains, can't go through them, why not go south? Hell, at its height the Persian empire stretched into the Indus river valley. Well.., this would require going though dense jungle, mosquitoes with diseases your top "scientists" can't even begin to explain the origin of, hostile people who are developing their own civilizations that might not take too kindly to you living off your land AND still have to go through the Mainland Southeast peninsula and do it all again before you reach China. In short, not going to happen.
But even if this geography weren't keeping the Persians away from China we have to look at the logistics behind the empire itself. While many empires (including the Persians) have had despots who's idea of cultural strength extended to "biggest empire is best empire" actually managing a large empire is hard. If you over extend yourself too fast you don't build infrastructure and/or get the conquered people on board to your empire. This is land you need to tax, enforce laws and protect from people from that non-arable land we looked at earlier. All the while you have an established trade partner who poses no threat to you or your people and have established trade routs actively benefiting the wealth of your empire. Merchants from both groups are willing to traverse those dangerous paths I previously mentioned, and best yet can do it for much fewer resources should you chose to sponsor their expedition. Even if China and the Middle East bordered with few physical barriers, there would be little point in engaging in a costly war when traffic is good on the silk road. Of course, if they didn't have those physical barriers, its likely the historical relationship between both sides of the mountains would be quite different.