There have been many posts already about HOW to do this. I can boil it down to A. Don't keep shoving your book under everyone's nose and "follow back" on Twitter just to up your follower count. And B. Make genuine connections with others by offering information of value, whether humor, support, or information.
But WHY? Why do this before we even get an agent? Isn't it a bit of a time waste?
Answer: Because by making GENUINE connections, you are gaining invaluable, reciprocal support from others like you. My writer peeps get me, and without them I might have given up at some point. Plus you demonstrate your ability to play well with others. Or not. (In which case, that's not as good for you as the agent or editor who may see that and avoid going down that road to begin with). But I digress and I suspect I'm preaching to the choir.
Caution! Don't get so wrapped up online that you get no writing time. It's easy to do. Set personal limits.