There are many interesting problems with this story. If it is a morality tale, it is a very poor one; the narration takes a neutral stance towards the events, God never appears in the story to cast judgment or censure anyone for their actions (as he does elsewhere in Genesis), Jacob warns that Simeon and Levi that they may face retaliation for what they had done but such retaliation never occurs, it is not clear whether Simeon and Levi acted heroically or foolishly, and so forth.
Instead, the point of the story in its current form is to provide an etiological legend to explain the political status of the tribes of Simeon and Levi in the nations of Israel and Judah. These are dispersed tribes which longer existed as territorial or political units by the time the stories were written. The key text in understanding the purpose of the story is Genesis 49:5-7, from the Blessing of Jacob:
"Simeon and Levi, brothers! Weapons of violence are their stock-in-trade. Into their company let me not come, in their assembly let me not rejoice. For in their anger, they killed a man; and when in a good mood, they maimed an ox! Cursed be their anger, so fierce, and their wrath, how unyielding! I will divide them up in Jacob and scatter them in Israel" (Genesis 49:5-7).
Most scholars recognize that the Blessing of Jacob is from an early source independent of the Yahwist, Elohist, and Priestly sources of Genesis, and there is no evidence that this specific passage was a direct source of the author(s) of the Dinah story (Genesis 34). Thus, this passage only mentions the murder of one man, not an entire populace, and nowhere elsewhere in Genesis do we know of a story of Simeon and Levi maiming an ox. However, both passages appear to draw on different traditions to depict the same thing: the violent past of the tribes of Levi and Simeon, as a reason why they no longer exist as political entities.
The diversity of tradition is apparent when we look beyond Genesis. The Dinah story (from J and E) places Simeon and Levi at Shechem, in central Israel, yet the Deuteronomical History assigns Simeon an inheritance derived from the territory of Judah (Joshua 19:1-9, 15:26-32, 42; 1 Chronicles 4:28-32), Judges 1:3-4 presents Judah and Simeon as united in their conquest of Canaan, and what are supposed to be Simeonite cities are placed within Judah as early as David's reign (cf. 1 Samuel 27:6, 30:30; 2 Samuel 24:7; 1 Kings 19:3). All this seems to reflect two streams of tradition: a northern tradition placing Simeon in the nation of Israel and a southern tradition placing the tribe in Judah. The omission of Simeon from the pre-exilic Blessing of Moses (Deuteronomy 33) may also reflect that loss of autonomy of the traditional group. The traditions about Levi are also diverse; in the Blessing of Jacob the tribe of Levi is "destroyed by its own ferocity" (Skinner), whereas in the Blessing of Moses (cf. Deuteronomy 33:8-11), Levi is the faithful priestly tribe that teaches the appropriate customs and Law throughout "Jacob", thanks to their scattered status (cf. Judges 17). As for the story itself in Genesis 34, it may combine two originally distinct narratives (e.g. a personal story focused on Shechem and his proposed marriage with Dinah, and a clan-oriented story focused on Hamor and his proposed marriage alliance with the sons of Jacob), and it has important literary links with two other independent stories in the OT: the rape of Tamar by Amnon in 2 Samuel 13 (avenged by Absalom), and the story of the attack and destruction of Shechem in Judges 9. The latter connection is most interesting. In Genesis 34:26-29, Simeon and Levi "put Hamor and his son Shechem to the sword ... pillaged the town ... took away all little children and their wives", yet Judges 9:28 refers to "the men of Hamor, the father of Shechem" still living in the town and then the chapter goes on to relate a story of a similar detruction of the city, with Abimelech having "slaughtered the people inside, razed the town and sowed it with salt" (v. 45). Even more telling is the reference to "the oak tree near Shechem" in the subsequent tale in Genesis 35:4, where Jacob buried the idols and earrings, and the "Oak-of-the-Pillar, which is in Shechem" (Judges 9:6), which is probably the same tree that was at "the temple of El-berith" at Shechem (v. 46-49) and the "Oak of Moreh at Shechem's holy place" in Genesis 12:6. In fact, it was at this very site that the Yahwist narrative in Genesis 12 has Abram building an altar to God and where Yahweh made a covenant (e.g. berith "covenant") with him to give the land to his descendants, whereas the Elohist source attributes the altar to Jacob who bought the land from Hamor, the father of Shechem, and dedicated the altar to "El", the god of Israel (33:18-20). Both stories appear to be distantly related cousins, both telling of a similar attack on the native Hamorites/Shechemites by Israelites (i.e. Levi and Simeon in one version, Abimelech in the other). The Dinah story would thus project the traditions of conflict between the Israelites and the Shechemites in the pre-monarchical period into a more distant time in the past, providing an even more root etiology of this conflict.
The folklore behind the clan-oriented Dinah story thus likely did not concern Simeon and Levi per se, but Israelites (or the sons of Jacob) in general who tried to make a marriage alliance with the Shechemites to destroy them. Note especially how the expected retaliation in v. 30 is forestalled by "a divine terror" which struck the surrounding towns so that "no one pursued the sons of Jacob" (Genesis 35:5). In fact, Jubilees has two stories of the sons of Jacob at Shechem: one expanding on the Dinah story in Genesis (cf. Jubilees 30), focusing on the wrongness of giving her in marriage to foreigners, and a later story in ch. 34 in which Jacob and his sons fight the Amorites at Shechem, killing them all by the edge of the sword, in a dispute about the flocks of Jacob's sons (cf. also Testament of Judah 3-7). This independent story (known also in the midrashism) has much in common with the Joshua and Judges stories of the Israelite conquest of Canaan and defeating Amorite or Canaanite kings. A clan-oriented story involving nothern Shechem (possibly originally set in the same Judges period as the Abimelech story) would have then been combined with a personal story about Dinah and revenge by her brothers Simeon and Levi, providing a new rationale for the attack on the city: what originally was a ruse to conquer the Shechemites in war became revenge for a personal violation. That two stories are being combined here is indicated by certain inconsistencies: (1) Shechem no longer had Dinah at the time he wanted to marry her (v. 4, 17) and yet in v. 26 she was in Shechem's house and had to be rescued by force, (2) Hamor is presented as negotiating a marriage alliance between the sons of Jacob and the town (v. 6-10), whereas Shechem himself is abruptly presented as making his own plea for a personal marriage with Dinah, on somewhat different terms (v. 11-12), (3) Hamor and Shechem took action to circumcise themselves so Shechem could marry Dinah (v. 19) without even the town as a whole knowing about the matrimonial alliance (v. 20-24), (4) Levi and Simeon are presented as alone attacking the city in v. 25-26 and criticized by Jacob in v. 30, and yet on the other hand the "sons of Jacob" in general are presented as attacking the city in v. 27-28. The redactor of Genesis, on this view, would have thus combined the two stories into a single patriarchical narrative, a story to explain why Simeon and Levi were cursed by Jacob in the Blessing of Jacob and described as especially violent. This curse, meanwhile, was designed to explain why the two tribes had ceased to have political status in the divided monarchy.