They are pretty similar, but で usually indicates that an action took place at that location.  So you use に when you're talking about _being_ inside or next to something, etc. and で when you talk about _doing something_ inside or next to something.