1550s, from Middle French cube (13c.) and directly from Latin cubus, from Greek kybos "a cube, a six-sided die, vertebra," perhaps from PIE root *keu(b)- "to bend, turn." Mathematical sense is from 1550s in English (it also was in the ancient Greek word: the Greeks threw with three dice; the highest possible roll was three sixes).
1580s in the mathematical sense; 1947 with meaning "cut in cubes," from cube (n.). The Greek verbal derivatives from the noun all referred to dice-throwing and gambling. Related: Cubed; cubing.