c. 1400, pille, "globular or ovoid mass of medicinal substance of a size convenient for swallowing," from Middle Dutch or Middle Low German pille and Old French pile, all from Latin pilula "pill," literally "little ball," diminutive of pila "a ball, playing ball," which is perhaps related to pilus "hair" if the original notion was "hairball."
The figurative sense "something disagreeable that must be accepted ('swallowed')" is from 1540s. The slang meaning "disagreeable or objectionable person, bore," is by 1871. The pill "contraceptive pill" is from 1957.
"rectangular wooden container," usually with a lid, Old English box, also the name of a type of shrub, from Late Latin buxis, from Greek pyxis "boxwood," pyxion "writing table, box," made of boxwood, from pyxos "box tree," which is of uncertain origin. Beekes suggests a loan-word from Italy, as that is where the tree is native. Dutch bus, German Büchse "box; barrel of a gun," also are Latin loan-words.
Meaning "compartment at a theater" is from c. 1600 (box seat in the theatrical sense is by 1850). Meaning "pigeon-hole at a post office" is from 1832. Meaning "television" is from 1950 (earlier "gramophone player," 1924). Meaning "station of a player in baseball" is from 1881. Graphics sense "space enclosed within borders and rules" is from 1929. Slang meaning "vulva" is attested 17c., according to "Dictionary of American Slang;" modern use seems to date from c. World War II, perhaps originally Australian, on notion of "box of tricks." Box lunch (n.) attested from 1899. The box set "multiple-album, CD or cassette issue of the work of an artist" is attested by 1955. To think or act outside the box "contrary to convention" is attested by 1994.