Why did General Charles Cornwallis retreat from the Carolinas and march north into Virginia?

Cornwallis had been ordered to pursue American

Commander Daniel Morgan.
Cornwallis had been ordered to take the offensive to
Yorktown, Virginia.

Cornwallis had decided he could not win the Carolinas after losing two key battles.