The problem is that you're starting the bars at the position of the ticks. That is, the left hand side of the bar is aligned with the respective tick, creating the impression that the bar isn't aligned because it is off center.
To fix, simply subtract barWidth/2
as an offset to the x
position of the bars. You'll also want to adjust the output range of your x scale such that the y axis and the first bar don't overlap.
x.range([barWidth/2, width]);
// etc.
rects.attr("x", function(d) { return x(d.month) - barWidth/2; })
Complete example here.