All these letters developed from the Semitic alphabet "waw", which was used for /w/ and /u/, via Greek and Latin. In Latin, the letter v still had these two ways of pronunciation.
Then happened language development in the European languages (see Takkats Answer for more information). Sounds shifted, scholars influenced the writing by different intentions, languages diversified and intermixed, …
The result in German was:
- 2 sounds: [f] and [v]
- 3 letters: f, v and w
- → f=[f], w=[v], v can be either one with absolutely no way to distinguish concerning roots.