Text wrap means if you have a long line of text when you constrain it to a certain width i.e. within the margins you set, the line of text breaks and 'wraps' to the line below. It's a weird term but that's what it means so in TextEdit 'wrap to window' means there are no margins and the text will essentially fill the window. Wrap to Page will wrap within the margins of the page. That's why you get the margin box appear so you can see where text will break/wrap.
Wrap to page is best for when you have a particular sized document that you need to print. This way you can see how it's going to print. Whereas wrap to window the text will move around depending on the width of the window giving no indication of how it will print.