Is there a difference between these two expressions and should one of them be preferred?
It depends on what you mean by purpose:
something that one hopes or intends to accomplish => "to this purpose" (as in "to this end", "to this intent", "to this objective", "to this target", ...)
the action for which a person or thing is specially fitted => "for this purpose" (as in "for this function", "for this job", "for this position", "for this task", ...)
For example, you will find both meanings in this gide "The Structure, Format, Content, and Style of a Journal-Style Scientific Paper":
In scientific studies, the use of this word (significant) implies that a statistical test was employed to make a decision about the data; [...].
Limit the use of the word "significant" to this purpose only.
Organize your presentation so your reader will understand the logical flow of the experiment(s); subheadings work well for this purpose