The history behind this is very long but it all comes down to the ha-line (ハ行) of the hiragana alphabet and how it has evolved over time.
Prior to the Nara Period, the letter and particle は was pronounced 'pa' and there was no 'wa' sound yet. Let's look at 川 (かわ) as an example.
-Prior to the Nara Period, 川 was written as かは and pronounced 'kapa.'
During the Nara Period, the pronunciation of は (the letter and particle) changed to 'fa.'
-So 川 was then pronounced 'kafa' (still written as かは)
This is where the big change happens. During the Heian Period, it was decided that は would be pronounced as 'wa' anytime it wasn't at the beginning of a word.
-Now 川 was pronounced as 'kawa' since the は wasn't the first letter of the word
-But 花 (はな) was still pronounced 'fana' since は was the first letter of the word.
-The particle は was still pronounced 'fa' since it was considered an independent word.
Between the Kamakura and Muromachi Periods in Japanese history, the particle は was no longer considered an independent word, but instead part of the word it followed. So by the previous rule, the particle は was then pronounced 'wa.'
After World War II, the alphabet was updated to reflect the modern pronunciation of words. In other words, writing the letter わ when the pronunciation called for the sound 'wa.'
-So finally, 川 was both written as かわ and pronounced 'kawa' formally as we know it today.
However, since the particle は is so commonly used in Japanese and they didn't want to over-complicate the change in writing-system, they decided not to change the writing of the particle は, even though it is pronounced 'wa.'
That's why the particle は is written with the character for 'ha' but pronounced 'wa.'