Let's begin with authorship. Both psalms include the header "לדוד", which many believe points to authorship by David. However, merely the header by itself is no proof that David actually wrote the psalm. First, "לדוד" could mean anything: "by David", "for David", "about David", or even "in the style of David". Second, we do not know who appended the headers onto the psalms and whether or not they knew or had a tradition regarding the authorship of the individual psalms. So let us put that aside as not real evidence either way.
Looking at the similarity between the two psalms, I see three ways to go:
- The psalms are almost identical. Therefore, they must be one and the same. It is not news to us that slight differences in texts creep up after centuries of copying, especially texts used for prayers like psalms. So we'll say that these two psalms are really the same psalm but one is earlier, and hence "less corrupted" than the other. Now the game becomes to figure out which is more "original".
- The psalms almost identical, but not quite. Why would the same author write practically the same psalm twice? More likely that a later composer used the earlier psalm and changed it a bit to fit his own meaning and whatever he was referring to in the psalm. Thus, they are two separate psalms written by two separate authors at two separate times. Now the game becomes to figure out what each psalm is about and what the differences mean.
- Same as number 2, but instead of saying that a later author changed the text of an earlier author, why not say that the same author changed his earlier composition to have it refer to different circumstances? So now we have one author of both psalms.
Options 2 and 3, although differing in the textual history of the psalm, both answer your question: "Why is the same psalm repeated"? Answer: It was intentionally "re-written" to address a different topic. Although there are only minor differences, these differences are important enough to make it a separate psalm. The compiler of the Book of Psalms then included both of them as they are two psalm about two different things.
Option 1, on the other hand, leaves us with your question. Why is the psalm repeated if it is indeed the same psalm with only textual variants?
A more critical scholar, like Rabbi Zvi Perez Chajes (in the Psalms volume of Avraham Kahane's "Tanach im Perush Mada'i"), would answer that the five books of the Psalms were compiled separately by different editors, then later combined together. Both book one and book two of Psalms included slightly different variants of this same psalm, and now we have two versions of it in the same book.
A more traditional scholar, like Professor Feivel Meltzer (in "P'nei Sefer Tehillim"), takes a different approach as follows: Although the two psalms are one and the same, and the textual variants evolved as normal textual variants, psalms are prayers of the people, and in the minds of the people, the differences mean different things regardless of the original author's intention. So the compiler included both because the differences between them are meaningful as they were understood by the people as prayers.
Prof. Meltzer's theory now leads us back to the game of option 2 and 3. How do we understand the difference between the two psalms? [Just now, instead of asking "What did the author mean?", we ask, "How did the people understand this as a prayer?"] As @Ephraim pointed out, Rashi understands them as referring to the first and second temples. Others understand that one is about evildoers and corrupt persons in general, while the other refers to a more specific evil personality, such as Sennacherib. Or one is about Jewish sinners and the other is about gentile oppressors. Whatever it may be, there is a reason why both psalms are included as separate psalms.