There are a few potential reasons for the North Korean artillery attack on a disputed South Korean island, and a few potential responses. Both are likely more complicated than meets the eye.
Potential Reasons for Attack
1) Kim is trying to re-set the "red line." In order to make sure it can secure a working nuclear weapons and deployment system, Kim Jong-Il might be trying to re-set what behavior actually leads to war (such that the nuclear program won't).
2) Kim Jong-Un is trying to display his power. Kim's successor may be trying to show domestic and international players that he is strong-armed and sufficiently aggressive that nobody thinks the shift in power will lead to a period of "softness" which could be taken advantage of.
3) An anti-Kim faction within the North Korean military may be trying to weaken the regime. After Kim Jong-Il came to power, a purge of military leadership struck fear into Kim's enemies, but also bolstered their sense of cohesion. Worries of another purge--or simply a sense of opportunism with the change of leadership--may be leading such a faction to provoke South Korea and the West into taking moves to weaken the Kim regime, up to war. Such a weakness or chaos might present an opportunity to stage a coup and replace the leadership.
Potential Responses by South Korean and Allies
1) The current response: the US joins South Korea's military exercises. The artillery shelling came during annual South Korean inter-service exercises in the Yellow Sea (which may tell us something about its motivations in North Korea). South Korea's response is measured, but the US has sent a carrier battle group to join the exercises. This serves both as a reaffirming of its commitment to South Korea's security, and also leaves open the option of precision air strikes against North Korea in the near future. Ths risk is that this response may look weak.
2) A tit-for-tat response. South Korea might attempt to show that it won't tolerate unprovoked attacks by reacting similarly: hitting a North Korean base. The risk is that North Korea may choose to escalate to show that it's willing to keep pushing to make sure it has the upper hand.
3) Tough sanctions. The US could rally a coalition for more sanctions against North Korea, but it's running out of options. Already, most countries avoid trading to North Korea in luxury goods (particularly those of which Kim Jong-Il is quite fond, like Mercedes cars). Broad sanctions would hurt an already-starving population, and would likely bolster North Korea's support for the regime, thus presenting a positive feedback to the North Korean military.
4) Significant escalation. South Korea could launch heavy surprise strikes against North Korea, both damaging its ability to wage war, and delivering an unambiguous message that further provocations would lead to destruction of the North Korean military (as South Korea would not make this move without US and Japanese support). The risk here is that North Korea would respond with artillery strikes against Seoul, where 25% of the South's population lives. Currently, North Korean artillery is so numerous and well-bunkered that it would be nigh-impossible to eliminate it before serious civilian tolls were suffered in Seoul.
The Chinese Response
The Chinese response has been intentionally cautious. North Korea as a tenuous ally has proven a liability, but China is largely unable to stop supporting the regime. If the regime collapses partially or entirely, China would be left with a humanitarian disaster and a refugee flood at its border (and under the Geneva conventions, it would be required to give them "reasonable" accommodation). China's current approach to North Korea is to make sure that the regime in power--whatever it may be--is stable. Unfortunately for China, this means supporting a temperamental and unpredictable Kim. At the same time, China will try to keep Kim in line as much as possible.
But Kim knows China is unable to stop its support, so China cannot use it as a serious threat (much like Israel knows the US is unwilling to drop its support entirely, and therefore the US cannot use it as a bargaining chip). China will need to find a way to temper North Korea's behaviour if it is going to be able to keep South Korea as a friend and trading partner (lest it lose South Korea to US/Japanese influence entirely).
Wisdom in the US Response
The US response shows strength and initiative to not only North Korea and China, but to the entire world. This is particularly important in a time when countries like Iran and Russia might see the US as exhausted or resource-drained from its commitments in Iraq and Afghanistan. The movement of its carrier battle group reminds potential rivals that its sea and air forces--the primary implements it would bring to bear in any engagement that wasn't a full-scale invasion--are still free, well-funded, and willing to move.
It also shores up South Korea's confidence in the US, which has balked at supporting countries like Georgia, Poland, and the Czech Republic against growing Russian influence and assertiveness. The move has marginally damaged relations with China, but the United States is showing South Korea that such damage is worth it in order to stick to its obligations.