that depends on your national law, but of course also on the materials you allow to be shared.
for instance, if you add a filter that makes sure that copyrighted material can not be shared, or, in those cases that it passes the filter, can be blocked when detected, you'll have a lot less legal problems than when you're just creating the next: let's share illegal software and warez here.
It depends. In the EU, Facilitating Copyright Theft by providing links to material (even if you do not provide any files) is illegal - hence the piratebay fiasco. Get legal advice.
If you are aiming to make the next big warez site, please leave now and never come back.
On the other hand, if I.E. you just want to provide torrents of your own stuff, which you hold the rights to (i.e. some software you have developed), then go ahead. Torrents themselves arent illegal, its just that they may be used for such means. Many opensorurce projects, for example, distribute large files using torrents to save on bandwidth.