This is certainly an interesting passage! First of all, although unusual, this is not the only such case in the Bible of those appearing who have previously died (see Moses and Elijah in Matthew 17). The medium at En Dor was clearly surprised and distressed by Samuel’s appearance; whether she typically was just very creative in “conjuring up” characters or was assisted through demonic deception, we don’t know, but Samuel was clearly not a “ghost-at-large” or a “wandering spirit.” The word she uses for “spirit” in v.13 is elohim, “mighty one.” He is sent as God graciously intervenes in the usual order of things to grant Saul one more encounter with the prophet/judge who had anointed him. Doesn’t it seem true that Samuel (and Moses and Elijah) were “present with the Lord” and continued to be so while on these special missions? (Since they were not at Samuel’s gravesite, I don’t think the medium’s statement that she “saw a spirit ascending out of the earth” requires us to conclude that this was Samuel’s dwelling place; this is in addition to the fact that he brought new revelation from God.)
In this case, as in Jesus’ Transfiguration, God had a particular purpose in allowing/sending these people to return and communicate. There is a clear re-statement by Samuel of God’s decision to remove Saul from the throne of Israel and the reason for it. There is an announcement of the death of Saul and his sons in battle the very next day! And yet in spite of Saul’s claims to want to know God’s will (v.5,6,15), when it is announced, there is no repentance or cry for mercy for himself or his sons or for Israel. The merciful, relenting character of God had been well documented in Israel’s history and in Saul’s own life (see 1 Sam. 22, 24, and 26), yet although terrified and despondent, he went to his death in stubborn pride rather than repent. (embarrassingly, I can identify!)
We can’t know with certainty how the Lord would have responded to genuine repentance from Saul, but we see His heart in His responses to Ahab (1 Kings 21:28,29), Jehu (2 Kings 10:28-31) Manasseh (2 Chronicles 33:1-20, esp. v.9-13) and us! (Romans 5:8-10)