That is too big a question for one topic.
You must do some research.
Fundamentally the tension in the rope is assumed to be the same throughout it's length and it is assumed that the rope does not stretch. The number of times the rope passes between the two blocks decides the total tension between the blocks.