Why is Miku shown with a leek?
Hatsune Miku holding a leek comes from a parody video of the Leekspin meme. The Leekspin meme is a video of Orihime from Bleach spinning a leek in one of the episodes with the Finnish folk song Ievan Polkka playing in the background.

On another note, the vegetable she is holding is actually a "negi" or green onion. However, the English dub for Bleach called it a leek.

Sources:


The Hatsune Miku parody video:
https://www.youtube.com/watch?v=kbbA9BhCTko
Leekspin meme: http://knowyourmeme.com/memes/leekspin-loituma-girl