Stack Exchange network consists of 183 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
The output doesn't seem bad. It's probably better in reality than your scope is showing, since the probe is loading the line. What you should check is the period -- measure the distance between two consecutive rising edges.
Right, I'll check for the 101st time, but I'm pretty sure it's just a typo in the question :) Anyway, it turns out that I've accidentally mistook LIVE wire for NEUTRAL and vice versa. Except that the switch is really connected to LIVE. Now it finally makes sense :) Your explanation of R3 is also quite reasonable. C4 remains a mystery to me.
You don't actually need the transistor or the diode, both are integrated on the relay (this is the one, isn't it? proton.cz.avg.com/plan/31399/?detail=746216654982669497). You do need to connect the 5V ground to the Arduino ground.
There are AC components in a squere wave. Opamps are linear elements, which means that they act on each frequency separately; however, each frequency is amplified with different gain and phase shift. This means that different components of the square wave will be amplified differently, leading to a distorted output. In practice, this will yield a nearly-square wave, but with vertical edges slightly skewed and rounded.