In this chapter, everyone jockeys to be David's friend and David crosses over the Jordan back into Israel.
This entire chapter is basically just the various interest groups in Israel rushing back to position themselves as supporters of David. Verse 10 puts it very clearly when Israel says, the man we wanted to be king is dead, and now we have another king coming back whether we like it or not, so maybe we should accept him instead. Having fully unified around Absalom, there is now considerable turmoil as the people adjust to this new reality that they were all traitors to the king, and if David feels like it, a lot of people are going to be dying soon. Remarkably, David punishes nobody upon his return. Even Shimei, the man who cursed him on his way out, escapes death for a second time simply because David himself refuses to kill Shimei.
But that's not how the chapter starts. It begins with David grieving over Absalom and it gets to a point where Joab has to come and knock some sense into him. I think Joab is right. David is humiliating his men by showing that he cared more for the son who fights against him than for the loyal men who were fighting and dying for his household. Remember that Absalom sought the death of David alone. All of his men could have turned and joined Absalom, even as Ahithophel did, and Absalom would have probably rewarded them for it. The men fought for David because they honor him and revere him, and David shows no regard for them whatsoever. In the end, David goes to meet his troops in the gateway, but I feel that David is less than wholehearted in this gesture.
Meanwhile, the rest of Israel was scattered in defeat and now find themselves in confusion. They are confronted by an awkward situation, having to bring back a king they firmly rejected. David himself also has an awkward situation, which is that Judah was the center of the rebellion against him. David is from the tribe of Judah and reigned from Hebron for the first seven years of his kingship (2 Sam 2:11), but Hebron is the very city where Absalom started his revolt. David needs firm support, but his own tribe betrayed him the most directly.
Nevertheless, David turns specifically to Judah to renew their support for him and bring him back across the Jordan. Crossing the Jordan is a fairly significant symbolic act, mimicking the original crossing of the Jordan when Israel entered the promised land. In this chapter, it appears to take on additional symbolism, almost like a coronation or inauguration of some official, and everyone wants to cross over with David as a sign of their support for him. David himself invites the men and elders of Judah to lead in bringing him back. From David's perspective, this is important because the rest of the nation is in confusion about whether they should support him. So I don't think it is a foregone conclusion that Israel would rally around David. Instead, David is seeking to build support in his own personal tribe, and then leverage that support into broader national support as he returns to Jerusalem. In a basic sense, David's plan works, but the upshot is that the northern tribes feel snubbed and this will shortly resolve into a more adversarial position.
David also appoints Amasa to take over the army in place of Joab. This is a significant political move and marks a shift in David's relationship with Joab. I have extensively detailed in my previous commentaries the several clashes between Joab and David. Joab murdered Abner, who was at peace with David, and then just recently Joab murdered Absalom contrary to David's instruction. At one point David says, "Today I am weak and these sons of Zeruiah are too strong for me", the sons of Zeruiah referring to Joab and his brother Abishai. David wanted to take action against Joab when Joab killed Abner, but he was afraid to do so because he depends on Joab to command the army.
In many other places, we see Joab successfully running the army and winning battles on behalf of David. Not the least of these battles is the one fought in the previous chapter, when Joab defeated the army of Absalom and resecured the throne on behalf of David. It is in the wake of this victory that David is demoting Joab and placing Amasa in his stead. We should see this in two lights. The first and most obvious is that David is trying to weaken Joab. Even though Joab has proven his loyalty to David many times, David is angry at Joab's violence and similarly he rebukes Abishai several times for his violent nature (like in verse 22 of this chapter). David is also angry at Joab's deceit and murder of Abner, and likely still wants to punish him for that crime.
The second aspect of David's decision is that he is promoting Amasa to, in a sense, reconcile himself with the supporters of Absalom. Amasa was the commander of Absalom's army, and in a strict sense he could be put to death for his betrayal. However, given the vast scope of the insurrection and the broad support for Absalom, David appears to be highlighting peaceful reconciliation with his erstwhile enemies as long as these people are willing to submit to him once again. This is the kind of decision that happened with the Rwandan genocide. In that case, the Rwandan genocide was murder committed on an epic scale, with up to 10% of the entire country's population implicated in one crime or another. If one person murders another, that person can be imprisoned or executed for the crime, but when an entire society commits murder, to punish that crime would require destroying the entire society. That is almost a nonsensical action, because one of the chief purposes of criminal justice is to preserve society.
In a similar way, if David were to punish all the men who betrayed him, he would essentially have to destroy the kingdom that he was ostensibly coming back to claim. Therefore, in several ways David chooses to show mercy and not punish any of the people who fought against him. First with Amasa, he shows mercy, and secondly with Shimei, David again shows mercy.
Shimei in particular knows that he is in deep trouble, and that's why he is one of the first to cross over when David is on his way back to Israel. Abishai threatened to kill Shimei when David was leaving for exile, so how much more is Shimei at risk of death when David returns. But instead David swears to not harm him. Contrary to how it appears now, David does not fully forgive Shimei, and on his deathbed he will charge Solomon (who reigns after him) to bring justice upon Shimei. But like I mentioned above, it is probable that David is trying to reconcile himself with the various tribes in light of their revolt, so he does not want to kill anyone when his own authority is still so tenuous.
Mephibosheth emerges again, and as I previously indicated, he challenges Ziba's testimony. Between the two of them, I think it's more likely that Ziba is telling the truth, but regardless of what I think, David decides that he cannot judge between the two of them, because he has no evidence to corroborate one against the other. Therefore he divides the estate between the two of them, reversing in part his previous judgment in favor of Ziba.
Barzillai emerges again, but to no significant effect this time. David offers him a royal pension, and Barzillai instead nominates some dude Chimham who is only ever mentioned in this one chapter. Presumably Chimham got to live a pretty sweet life being directly subsidized by the king, but his affairs are otherwise inconsequential.
This chapter concludes with the men of Judah getting into a dispute with the men of Israel, the ten northern tribes (the two southern tribes most likely being Judah and Simeon, or possibly Judah and Levi). Both Judah and the northern tribes (referred to as the "men of Israel", because Israel becomes a cognomen of sorts for the northern tribes) were reluctant to get involved with bringing David back until David took the initiative and, in essence, brought himself back by reaching out to Judah. So it's with more than a little irony that Judah and the men of Israel are now arguing about who should have had the right to bring the king back, when earlier in this chapter they were debating whether the king should be brought back at all. This reminds me of the story from Judges 12 when the men of Ephraim become jealous of Jephthah's victory and they actually fight a war over it, because Ephraim felt dishonored by being left out of Jephthah's army.
In the same way, the "men of Israel" feel dishonored because Judah was given the place of honor in bringing back the king, when they represent "ten parts", having ten out of the twelve tribes.