a while – a period of time (noun phrase). We'll be there in a while. (Note that this noun phase is the object of the preposition: in a while, for a while, after a while.) All the while, he kept calling. (during that time)
awhile – for a short period of time (P), briefly (Adv), temporarily (Adv). We'll be there awhile. Let's rest awhile. Prefix a- originates historically from on but now includes to, in, into, on. See source below.
Huddleston, Rodney D. and Geoffrey K. Pullum. "Prepositions vs. Adverbs." 7 §2.4. The Cambridge Grammar of the English Language. Cambridge UP, 2002.
Taxi cabs stopped in traffic. Pixabay, 21 July 2013. Licensed by CC0. Accessed 2 Mar. 2019.