c. 1300, "one at dice," from Old French as "one at dice" (12c.), from Latin as "a unit, one, a whole, unity;" also the name of a small Roman coin (originally a rectangular bronze plaque weighing one pound, it eventually was reduced by depreciation to half an ounce; in imperial times it became a round coin). The Latin word also is the source of Spanish as, Italian asso, German ass, Dutch aas, Danish es. It is perhaps originally Etruscan and related to Greek heis "one" (from PIE root *sem- (1) "one, as one"), or it might be taken directly into Latin from the Greek word.
In English, it meant the side of the die with only one mark before it meant the playing card with one pip (1530s). Because this was the lowest roll at dice, ace was used metaphorically in Middle English for "bad luck" or "something of no value;" but as the ace often is the highest playing card, the extended senses based on "excellence, good quality" arose 18c. as card-playing became popular. Ace in the hole in the figurative sense of "concealed advantage" is attested from 1904, from crooked stud poker deals.
Meaning "outstanding pilot" dates from 1917 (technically, in World War I aviators' jargon, one who has brought down 10 enemy planes, though originally in reference to 5 shot down), from French l'ace (1915), which, according to Bruce Robertson (ed.) "Air Aces of the 1914-1918 War" was used in prewar French sporting publications for "top of the deck" boxers, cyclists, etc. Sports meaning "point scored" (1819) led to sense of "unreturnable serve" (by 1889).