What is the purpose of the scale at the top in TextEdit
It is a Tab ruler, for setting indents, tab stops and other text alignments.

Apple explains it fully here:

Adjust margins and paragraphs in TextEdit on Mac