We're skipping ahead a good bit in our story of David and Saul. In yesterday's reading David and Jonathan find out that Saul definitely wants to kill David, so Jonathan and David say their good byes and David leaves. He spends some time on the run with a couple of momentary reconciliations with Saul. During that time people from all over Israel who were in trouble came to stay with David. This motley crew became the core of David's power as he moved towards the throne.
At one point David came to the Philistines and lived there, even though Israel and the Philistines were at war. As I Samuel ends, Saul and Jonathan go to war with the Philistines and are killed in battle. When David hears the news he composes this song of mourning. We can believe easily that David is sad about Jonathan's death. His grief over Saul's death may be less genuine, but very useful to establish for Israel that David didn't have a hand in Saul's death. This feeling of innocence will be important as David seeks to cement his rule over all Israel in the coming years. Plus, it's quite a lovely, melancholy song.