In Illustrator how can I merge this roof vector to the background of the square?
As @Bart Arondson has pointed out, what you want to use is a clipping mask.
This is how it works:
You need to group your roof-tiles first. Select all of them with the black selection arrow, and use cmd+G or go to
Object -> Group.
Then you make sure your square is on top of the roof-tiles group. Pretend this multicoloured pattern is your roof.
Select both roof and box and go to
Object -> Clipping mask -> make:
That should give you this result: