It comes from the Latin word "paene" meaning "almost" or "nearly".
The word "penultimate" itself means "next to last".