様(よう) is "a word that expresses the state of things". に is a target particle. Therefore, if it helps you understand, ように means "towards a certain state". So when I say something like
明日は晴れるように — May it be sunny tomorrow I'm saying "towards the state of things where it's sunny". As happens frequently in Japanese, I am omitting the verb of this sentence because it is obvious in context.
明日は晴れるように祈ります — I pray it may be sunny tomorrow It expresses a yearning for a particular 様(よう).