You really don't understand the context, do you?
The Perugia police and PM had a grisly, high-profile murder on their hands. Media from around the world were descending on the city. The details of the murder were being reported worldwide. The murder was of a young British female exchange student. Students were deserting Perugia in their droves. Perugia was not doing very well at all out of the situation while the murderer(s) was still at large.
In addition, I think there's another very important factor. Almost exactly one year previously, another female student (Italian) had been murdered. The Perugia police and PM totally botched that investigation. It appears that the woman's boyfriend was the likely killer, but the whole investigation - from forensics through to witness statements and other lines of investigation - was so badly messed up that there never was sufficient evidence to arrest the boyfriend, let alone charge or convict him.
I believe the Perugia police and PM dept were still smarting over their public humiliation on that case. And they had the world watching them now with the Kercher case. They needed to "solve" it. Fast.
And by the afternoon of 5th November, they thought they HAD solved it. They'd phone tapped all and sundry (a dreadful breach of human rights in the breadth of tapping and the nature of authorisations, but that's another matter...), and they'd obtained everyone's phone records for the night of the murder. They'd already come to the (erroneous) conclusion that the break-in was staged (largely based, it would appear, on the risible basis that since not much was stolen, this can't have been a "proper" break-in!). They saw from the phone records that Knox had exchanged text messages with someone on the night of the murder. Knox, in interviews, had not admitted to this exchange. They had also been tailing Knox, and they'd seen Knox talking with Lumumba (whose name they had probably tied by now to the number Knox was texting on the night of the murder). And Knox had no alibi other than that supplied by Sollecito, who was telling the police (as was Knox of course) that Knox and he had spent the whole night in his apartment.
So now the cogs started turning. Knox had "lied" (by omission) about the text message exchange on the night of the murder. She had also been seen meeting with the man (Lumumba) in question since the murder. "Aha!" they concluded: Knox must have been arranging to meet up with Lumumba on the night of the murder, and the meetings they'd observed after the murder were "obviously" concerned with Lumumba asking Knox how much she thought the police/PM knew. And since the police/PM had concluded that the break-in was staged, they also (erroneously) concluded that the only people with the motive to stage a break-in were the other occupants of the cottage. Laura and Filomena had well-corroborated alibis. Knox had only Sollecito to corroborate hers. "Aha!" thought the police: Sollecito "must" be lying to protect Knox, since she has him under some sort of dominant spell and he was besotted by her.
So the police and PM put 2+2 together and got 439. They allowed themselves to get swept up in confirmation bias and tunnel vision completely at this point. They were now convinced they'd figured it all out. From that point on, everything they did was tainted by their need to fit it to this "truth" that they'd decided upon. They were excited and self-aggrandising, since they truly believed they'd solved this case within 5 days of the murder. They would been viewed as crack detectives and PM by the community and by the international media who were hanging on their every word. The pride and hubris were palpable within the police HQ and the PM's office.
So in summary, this was NEVER about "trying to frame a couple of whacky kids". In fact, it's reductive and rather naive to think that this was the case. Instead, it was about a desperation from the Perugia police and PM to solve the case as soon as possible. They truly thought they HAD solved it (though their analysis and thinking were dreadfully flawed). And from then on it became an ugly, unfair, unlawful and incompetent attempt to save face as their edifice crumbled around them. Unfortunately for Knox and Sollecito, the Italian criminal justice system was/is so dreadfully inept and unfit-for-purpose that it took several long years for them to get the justice that they deserved (and Knox and Sollecito deserve justice just as much as Kercher and her family).