I asked this question before, but got no response so am trying again. The Wikipedia page is very bare. It mentions a previous massacre of foreigners a hundred years before by pirates and then the fact that a rebel army again massacred the foreign merchants in the city.
I am just wondering if I could have a bit of background into the city, the regional issues, etc. Considering how closed off china has been, such a large foreign population seems even bigger. I'm guessing it was a trade port, but for what? And if it had been previously massacred within a hundred years, why did people come back and remain unprotected?
You're asking about the sack of one of the most important cities in China, which took place in the middle of a rebellion that played a major part in shaping the history of the Middle Kingdom for several hundred years to come. So it's unfortunate that the sources that survive for the events of 879 (not 878, as Wiki has it) are not only pretty meagre, but frequently contradictory.
For all these reasons, constructing a full answer worthy of this question is going to take some time – so I'll start with the short version.
We're not quite certain about this last point; accounts differ. All of which brings us on to...
Sources
The two Chinese dynastic histories that cover the late Tang state were both compiled more than 200 years after the events they describe, and they contain little more than a passing mention of what happened at Guangzhou – which was then probably the largest port in southern China. Our main Arab source, in the meantime – which is where the estimates of six-figure deaths is drawn from – was compiled by a man who never left the Abbasid caliphate, so it's probably best to begin this response with an acknowledgement that the figure of 120,000 deaths cannot be proven, and is almost certainly best understood (like most medieval figures of this sort) to mean simply that "a lot of people died." Since the Chinese sources that we have offer no detailed discussion at all of what happened at Guangzhou, it wouldn't even be safe to presume that the rebels specifically targeted foreign merchants. I'll come back to this point later.
As for that Arabic source I mentioned, it is Accounts of China and India, a book of akhbar – a compilation of oral accounts, supposedly taken down verbatim but more likely polished by the compiler – set down in two distinct parts, about a century apart. The earlier portion that we are most interested in is traditionally attributed to Sulaymān al-Tājir (that is, "Sulaiman the Merchant"), though he was at most only one of a number of travellers who apparently contributed accounts to an anonymous compiler. Although there are quibbles about some of the material contained in this portion of the Accounts, internal evidence suggests that much of the book does rest solidly on material contributed by merchants who had travelled to China and who had ranged almost as far north as the Korean peninsula.
From the particular perspective of this question, however, we have to note one significant problem with the Arab sources: the material contributed by Abbasid travellers who we can be fairly confident had actually visited China dates to c.851, before the sack of Guangzhou. The information we have about the sack of the city itself comes from the second part of the Accounts, which was compiled in about 916 by an Arab geographer named Abu Zayd al-Hasan al-Sirafi. Abu Zayd, as his name indicates, came from the Gulf port of Siraf, at the western end of the sea route to China, but he never travelled to the east, and his portion of the book is less clearly sourced than the part usually attributed to Sulaymān al-Tājir. For this reason, and while there's certainly no reason to write it off completely, the second part of the Accounts is usually considered less reliable than the first half of the book. I'd suggest we need to be very cautious of the figures that it offers, including that for the number of dead at Guangzhou.
With all this said, however, there's no obvious reason to doubt that the foreign trade that passed through Guangzhou was pretty significant, nor that the sack of the city did not result in the deaths of a very high proportion of the foreign merchants who had based themselves there, and every reason to think that the commerce they were engaged in was important for both the caliphate and for China. Thanks in part to some recent archaeological advances, especially the discovery of several important shipwrecks, we know quite a bit more about this trade than we did even a couple of decades ago, so it is now possible to look in some detail not only at the ways in which merchants lived and worked in Guangzhou, and at what the city meant to the Tang state, but also at the fundamentals of the transoceanic trade itself.