へ and に tend to be used the same.
But they are originally a bit different.
I went to the book store. 私は本屋へ行った
Explaining the fact that you went to the book store but this sentence is not talking about the purpose.
I went to the book store to buy a book 私は本屋へ本を買いにいった
Explaining the fact that you went to the book store to buy a book.
I went to the book store (to buy a book.) 私は本屋に(本を買いに)行った
Explaining the fact that you went to the book store, and implying you went there with a purpose.
Poeple can probably tell that you went there to buy books.
Another example,
I went to the bank (私は銀行[へ]行った)-> telling the fact
I went to the bank to withdraw some money. (私は銀行 [へ] お金をおろし[に]行った) -> telling the fact and purpose
I went to the bank (私は銀行[に]行った) = (私は銀行(へお金をおろし)[に]行った)-> implying there was a purose to get some money
But I would say those are pretty much interchangeable recently.