The word outlasted the breakdown of gender in Middle English and survived as a secondary form of two, then especially in the cases where the numeral follows a noun. Its continuation into modern times was aided by its use in KJV, the Marriage Service, in poetry (where it's commonly used as a rhyme word), and in oral use where it is necessary to be clear that two and not "to" or "too" is meant.
It could look like one of the many English words inherited from Old Norse. The modern Danish word is "tvende" (pronounced tvenne), it means both, two of a kind, etc.
- (dated) two
- But the warm twilight round us twain will never rise again.
- Bring me these twain cups of wine and water, and let us drink from the one we feel more befitting of this day.
- (Can we date this quote?) Kipling
- And never the twain shall meet.
- 1866, Algernon Swinburne, Before Parting, lines 1-2
- A month or twain to live on honeycomb
- Is pleasant;
- 1900, Ernest Dowson, Amor Profanus, lines 26-28
- […] all too soon we twain shall tread
- The bitter pastures of the dead:
- Estranged, sad spectres of the night.