The reason Hu'er left only 5000 soldiers in the city was that he trusted his son and the old subordinates who had shared life and death with him to guard the city. On the other hand, he thought that he could defeat Wu's army by ambush. Even if the ambush failed, he could retreat back to the city safely with this force of 15000 people.