Purpose
The use of typography to censor words was to avoid breaking obscenity laws, and it was blasphemous to make fun of religion. Religious words were censored more than "normal" swear words, and were only censored when used as part of oaths; normal use was unbleeped. Dashes were used to obfuscate from the mid-17th century and throughout the 18th century and asterisks were common from the 19th century on.
1710
Eliminative dashes, as in D--n for Damn can be found as early as 1710 in The Tatler (found via The Anatomy of Swearing (2001) by Ashley Montagu):
D---n you all, for a set of sons of whores; you will stop here to be paid by the hour! ... Why, and be d------d to you, do you not drive over that fellow?
1687
Earlier than then Rigby sodomy trial of 1698 is this citation in the OED for shit:
a1687 Duke of Buckingham Instalment in Wks. (1705) II. 88 You're such a scurvy..Knight, That when you speak a Man wou'd swear you S——te.
1688
Mark Liberman of Language Log searched LION (LIterature ONline) and found Richard Ames's "A Satyr Again Man", from Sylvia's Revenge (1688):
314 Bully how great i'th' Mouth the Accent sounds;
315 Bully who nothing breaths but Bl---d and W--nds?
1680
The same Language Log post has John Oldham's poem "Upon the Author of a Play call'd Sodom" from Works (1680):
26 Whence nauseous Rhymes, by filthy Births proceed,
27 As Maggots, in some T---rd, ingendring breed.
1684
Jack Horntip has a fascinating collection of books from the 17th century to today. Several contain typo-bleeping, but it may be that some of them are later (sometimes 19th century) reprints with censoring added at the later time, and the originals may have been uncensored.
The following are all from the Jack Horntip Collection and most only show the raw OCR (plain scanned text). It's possible they're from later printings, but from the first pages I get the impression they're the original typography. However, they could be later, edited, "facsimile" re-printings, as I'm unsure if the years would be written in Roman or Arabic numerals at this time. (These should all be available online in the Early English Books Online database for further verification.)
Edit: I've confirmed these in the EEBO database.
The earliest that has a full PDF is in Sodom or the Quintessence of Debauchery (1684) by the Earl of Rochester, which is chock full of all sorts of uncensored sexual language but bleeps out "heaven[s]", "almighty", "God[s]" (although there's a single "p—s"), for example:
Al . . . ty Cunts, whom Bolloxinion here
Say what you want, but be careful of the Church!
1675
Mock Songs and Jovial Poems (1675):
You'd find the Perfume,
Almost as strong as it was:
Nay, she had such an Art,
In Letting a F—,
I mean for the Noise and Smell;
1672
Covent Garden Drolery 2nd Ed. (date also shown on the scanned first page):
Now he that sate here had much the better pjace,
He broke not his Neck, though he wetted his Ar—
For by th'ill successive disposure of th'other
Folks saw, and they tumbled too, one o're another,
1658
Wit Restor'd by John Mennes issued in 1658:
In rythem daigne goddess to accept my verses,
I wis with worse wise men have wip't their A—
O thou which able art to take to taske all
(Pox! what will rythme to that?) oh, I'me a raskall,
1656
John Philips' Sportive Wit (1656) is chock-full of bleepos. Here's some extracts.
Here 's a Health to my Lady Kent,
that hath a bounsing C —--;
And to my Lord her husband.
that tickl'd my Lady Hunt.
-
These are they bear the sway
And keep the money;
Which he may better do,
Than his wife's ---
-
She hath a buttock plump,
Keep but thy T--- whole:
She will hold up the rump
With her black A --- hole.
-
About this T--- there stuck
Many a broken plum,
All fritter'd with a fart
Which came out of her bum,
And made it smart.
-
Take a Lady in the grasse,
Clap her ---
--- her well and let her passe;
Upon the bed then let her tumble,
Put it in,
Put it in she'l never grumble.
-
And you shall never gain a penny,
But still they will be plucking.
And think that they shall never have
Their bellies full of ---.
-
Come husband, away with this filthy curre,
It makes my flesh to rise,
He left off all, and to her did fall,
And slipt between her ---
-
On Tobacco.
WHen I do smoak my nose with a pipe of Tobacco after a feast,
Then down let I my hose, and with paper do wipe mine — like a beast.
It so doth please my minde,
It doth so case behinde,
For to wipe,
For to wipe my tewel.
Tobacco's my delight,
So 't is mine to sh —
Oh fine smack,
Oh brave cack my jewel.
Searching Early English Books Online, I've found an earlier typo-bleepo.
1651
James Smith's The Loves of Hero and Leander a mock poem : with marginall notes, and other choice pieces of drollery (page 14, EEBO):
He tooke him to a trusty rock,
And stript him to the ebon nock.
And being naked look't like Mars,
With purple scab upon his A---
Best Answer
The word swear comes from the Old English swerian (past tense swor / pp sworen), meaning a solemn oath.
In the original use, swear means a solemn promise ("I swear that"), made to someone ("I swear to"), optionally with collateral put down in the event that the promise is broken ("I swear on"), for instance "I swear on my life", "I swear on my homestead" or "I swear on my honor".
Note that you swear to somebody. For instance, "I swear allegiance to my liege" means I promise loyalty to my lord/king.
"I swear to God" evolved from this meaning a solemn promise to God — generally as an appeal to a higher power for increasing the weight of a promise ("I swear to God that I will pay my rent by next week") or as a way of adding emphasis and solemnity when announcing a self-imposed duty e.g. "I swear to God that I will find the perpetrator of this crime".
The extended meaning (i.e. as an expletive) comes from medieval times (c. early 15 century) in relation to "I swear to God". In the event that someone broke this promise, it was interpreted by many (including the Catholic Church) as a sin, because it was a taken as a direct breach of the third commandment:
Note that the objection here is not "taking the name of the Lord" (i.e. swearing to God), but rather taking it in Vain — i.e. swearing to God and subsequently breaking the promise.
The notion of swearing being overtly bad, or crude, evolved from this meaning — where saying "I swear to God" is a solemn oath not to be taken lightly — for fear of going to hell.
For this reason, invoking sacred names over trivial incidents was therefore something that was not to be done in polite company, and something that children should be actively discouraged by their parents from doing.
Until the mid 1700s, use of obscenities ("cursing") was treated completely separately, and during the mid 1700s the two became lumped together as "swearing and cursing". By the mid to late 1700s this was being frequently shortened to "swearing", and the term "swearing and cursing" eventually petered out in the mid 1800s.
The word swearword is an American English colloquialism from roughly 1883.
In modern English, swear meaning to promise has become increasingly uncommon except perhaps in legal contexts and particularly in American English — and consequently "I swear to God" meaning a solemn promise to God would be a very archaic interpretation. The meaning of "I swear to God" nowadays is pretty much exclusively used as an expletive.