In Devarim 21:18-21 the Torah says, "If there is a wayward and rebellious son who does not listen to his parents, his mother and father should reprimand him (Rashi - by bringing him to Bait Din for a warning). Then, his father and mother should take him out to the elders of the city and they should say, "This son of ours is wayward and rebellious and does not listen to our voices; he is a glutton and a drunkard. All of the men of the city shall pelt him with stones and he shall die...."
The Gemara in the eighth Perek of Masechet Sanhedrin (68b) (entitled Ben Sorer Umoreh) states that the reason the boy is killed is because of the fear that later in his life he might commit an egregious sin. The boy , the Gemara says, has an addiction to wine and meat and he may murder to satisfy his addiction. This statement implies that his personality is one inclined to murder and to avoid this possibility, he is killed.
The Gemara explains how precise the criteria of the Torah are in order for one to be considered a Ben Sorer Umoreh. The Mishna (68b) introduces the issue of the exact time a boy can become a Ben Sorer Umoreh, the Gemara concluded by deciding that it depends on what stage of puberty he is in. The Gemara (69a) raise a Machloket regarding how much time the Bait Din has to kill the boy. One opinion says thirteen years and three months of age and the other says thirteen years and two and 1/3 months of age. The Gemara (70a) then requires the boy to have consumed an unusually large amount of certain types of meat and wine. From the many exacting criteria, Rabbi Shimon (71a) states, "A Ben Sorer Umoreh never happened and will never happen, and the only purpose of the Halacha is to receive reward for its study."
The Kli Yakar amplifies with Rabbi Shimon's statement and feels that the reason for this Mitzva is exclusively to instill fear into one's children in order that they perform the Mitzvot which deal with honoring parents (the fear of being killed for their actions will make them act as better people). By the parents instilling fear into the children, they will become better Bnai Torah. The Kli Yakar then mentions that according to this explanation this Mitzva should even apply to women as well (in contrast to the Gemara feels that from the Pasuk which states 'Ben' that only males are included in this Mitzva).
We can see that the Torah did not necessarily intend to make this a direct Mitzvah, but rather these Pesukim come to instill the important character trait into Bnai Yisrael that in all of their actions they should be an Am Kadosh, a holy nation.