OED has as its earliest citation an extract from Kipling's Captain Courageous (1897):
13 a. To be agreeable or convenient to (a person, his inclinations, etc.); to fall in with the views or wishes of.
13 b. suit yourself v. do (or think) as you please, please yourself. colloq.
1897 R. Kipling Capt. Courageous i. 21 ‘You stole it.’ ‘Suit yourself. We stole it ef it's any comfort to you.’
There are certainly earlier occurrences of the phrase in related (but not entirely identical) senses.
1831 J. Newton, R. Cecil The select works of the Revd John Newton p.240 "I hope you will endeavour likewise, to be plain and familiar in your language and manner (though not low or vulgar) so as to suit yourself as much as possible to the apprehensions of the most ignorant people."
"Suit yourself to something" means "adapt yourself", "to make yourself agreeable to"; whereas just "suit yourself" as in 13b means "whatever is agreeable to you".
Etymonline gives the etymology.
suit (v.)
"be agreeable or convenient," 1570s, from suit (n.), probably from the notion of "provide with a set of new clothes."
suit (n.) c.1300, "attendance at court, the company attending," also their livery or uniform, via Anglo-French siwte, from Old French suitte "attendance, act of following," from Gallo-Romance *sequita, fem. of *sequitus, from Latin secutus, past participle of sequi "to attend, follow" (see sequel). Meaning "application to a court for justice, lawsuit" is first recorded early 15c. Meaning "set of clothes to be worn together" is attested from early 15c., from notion of the livery or uniform of court attendants (a sense recorded from late 13c.).