If you've ever spent time doing research, or trying to get information from people, you'll understand why we call it legwork: It's something that takes physical effort, and it usually means you have to get out from behind a desk.
Legwork refers to the work that happens when a project is in an early stage. You could be asking people for interviews, collecting information, conducting surveys — the possibilities are endless! It's called legwork because it contrasts with sitting down to write up what you found out. These days, though, a lot of legwork also happens from behind a desk: If you're gathering information or other material for a project, you can still call it legwork, even if you didn't travel or walk around to do it.