原来 + [clause]
[subject] + 原来 + [verb phrase]
原来的 + [noun]
原来 at the start of a clause says you've just found out something you didn't know: "so it turns out", "so that's it". It usually opens the sentence, before the subject.
The discovery often explains something odd you'd noticed. 难怪 or 怪不得 can then sum it up.
原来如此 is a set reply: "I see, so that's how it is".
After the subject, 原来 means "originally, formerly": how something used to be before it changed.
In this sense it overlaps with 本来, but only 原来 marks a discovery.
Before a noun, 原来的 means "original, former": 原来的地址, "the old address".