Short answer: to rebuild his memories without destroying him in the process.
Sora lost his memories while inside Castle Oblivion, a place that strips visitors of their recollections. That matters because Sora is the Keyblade wielder — the one who can defeat the Heartless and who is needed to protect the worlds from both them and Organization XIII, a group of Nobodies trying to harness his power to complete Kingdom Hearts and gain hearts of their own.
He needs those memories back in order to remember Kairi, Riku and the reason he is fighting at all.
Namine has the ability to reshape Sora's memory and the memories of those connected to him, since Kairi is her other half. Restoring the old memories meant removing the ones formed at the castle — and doing that while Sora was awake would have hit him all at once. The sleep is essentially the anaesthetic: it lets the swap happen safely, much like being put under for surgery.
To see what Sora missed during that year, Kingdom Hearts 358/2 Days covers it on Nintendo DS.