Yes, that gap is 100% essential to being able to use the pegboard! Without it, you won't be able to slip in hooks. Just use a piece of 1x2 as a spacer between the pegboard and the wall.