The majority of the time, there's no direct answer for that. Pin number and color code are easy; they're there on the diagrams. Function? Sometimes there's really no way to know, especially since so many of them are 'black-boxed' and BMW doesn't want to tell you.
Sometimes, tracing that wire through to whatever's on the other end helps. Light wiring on a E46 generally centralizes back to the LCM in the dash. Good thing about that is that we've already figured that part out.