I have started to notice that a few words in English – largely in more formal or older works – have seemingly unnecessary compound words such as inasmuch or insofar. I assume that there are more words which follow a similar pattern, with "in" to start the compound, and "as" as the next word. Why is it that these words are compounded? Also, how did these compound words come into existence?
How—or rather, when—did these fused words come into existence
I ran Google Books searches for the fused forms of eleven three-piece words—albeit, forasmuch, hereinafter, hereinbefore, howbeit, inasmuch, insofar, thereinafter, whatsoever, whosoever, and wheresoever—for the period 1600–1900, to identify when the earliest matches appeared. Here are the results I obtained (first occurrence in parentheses):
1Orlando Bridgman, Conveyances, consisting of legal documents drawn up at various times prior to 1674, consistently renders hereinafter as herein after.
2A statute enacted in 1729 under George II appears to render the term as herein before.
3A Scottish assembly declaration in 1581 and another in 1596 (cited in the same source) use in so far.
Google Books search results aren't rigorous: The underlying database isn't exhaustive, and OCR errors prevent Google Books searches from noticing all occurrences that actually occur. Still, the results I compiled do suggest a couple of things. First, people writing in English have been using fused forms for a long time; and second, the fusion of such words didn't occur all at once. Seven of the fused words are attested in Google Books matches from not later than 1611, but the other four occur for the first time in Google Books matches from 1685–1775. The latecomers were hereinafter, insofar, hereinbefore, and thereinafter.
Why did the fusion take place?
You might expect that the fused form inasmuch as emerged in contradistinction to the open form in as much as as a way of crystallizing some difference in meaning between the two forms—but I haven't found any evidence that such a thing happened. Another possibility is that the phrase appeared so often in certain ritualistic documents (such as deeds of conveyance) that scriveners came to think of insofar as single entity and so began to render is as a single fused word instead of as three separate words.
Henry Fowler & Francis Fowler, The King's English (1906) takes a very dim view of modern (in 1906) use of the term inasmuch as (and similar phrases) in a subsection titled "Compound prepositions and conjunctions":
The increasing use of these [compounds] is much to be regretted. They, and the love for abstract expression with which they are closely allied, are responsible for much of what is flaccid, diffuse, and nerveless, in modern writing. They are generally, no doubt, invented by persons who want to express a more precise shade of meaning than they can find in anything already existing; but they are soon caught up by others who not only do not need the new delicate instrument, but do not understand it. Inasmuch as, for instance, originally expressed that the truth of its clause gave the exact measure of the truth that belonged to the main sentence. So (from the Oxford Dictionary):
God is only God inasmuch as he is the Moral Governor of the world.—SIR W[ILLIAM] HAMILTON 
But long before Hamilton's day the word passed, very naturally, into the meaning, for which it need never have been invented, of since or because. ... The best thing we can now do with inasmuch as is to get it decently buried; when it means since, since is better; when it means what it once meant, no one understands it.
Henry Fowler, Modern English Usage (1926) is even less charitable toward in so far [as or that]:
in so far. He must have a long spoon that sup with the devil; & the safest way of dealing with in so far is to keep clear of it. The dangers range from mere feebleness or wordiness, through pleonasm or confusion of forms, & inaccuracy of meaning, to false grammar.
Presumably, Fowler would have greeted the fused form insofar with garlic, mirrors, and crosses.
The Ngram chart for "inasmuch as" (blue line) versus "in as much as" (red line) for the years 1900–2000 shows that the fused form is still considerably more common in English writing than the open form and that it has been so for at least 200 years:
"Insofar" (blue line) versus "in so far" (red line), tracked over the same period, presents a very different case: The open form for many years dominated usage, and not until 1971 did the fused form pass the open form in Google Books frequency:
Looking at these two charts, I speculate that the fused form insofar became popular simply because it imitates the established form inasmuch. At any rate, I can't see any other consideration that would tend to promote the closed form insofar at the expense of the open form in so far.
The process is called univerbation:
- (linguistics) The diachronic process of forming a new single word from a fixed expression of several words
The adverbial expressions you cite date back to the 13th century, but their usage as one single word developed later, around the 17th and 18th century, probably as a result of the their continuos usage as short set phrases.
- late 14c. as a phrase; tending to be run together from 16c.;
- contraction of phrase in as much "to such a degree," which is first attested c. 1300 as in als mikel, a Northern form. Contracted to in asmuch, then, beginning 14c. and especially since 17c., to one word.
A more recent example which has followed the same usage pattern is nonetheless:
- 1839, as phrase none the less; contracted into one word from c. 1930. (Etymonline)
Insofar appears to be an exception among these contracted expressions in that both forms "insofar and in so far" are used though the one word version is more common in AmE than in BrE:
The preposition and adverb insofar, meaning to such an extent, is one word in American and Canadian English. It’s usually three words, in so far, in varieties of English from outside North America—though the one-word version is gaining ground everywere.
In many cases, the formal-sounding insofar as could be either removed or replaced with a shorter alternative. Even the three-word as far as is shorter (in syllables) and usually more natural