The thesis should be the heart of your graduate school career. It will certainly be the most involved and difficult thing you do while in grad school.
Of course, before writing the thesis, one needs to have research to report. To make things easier on yourself, it’s a good idea to record your results as you work. Don’t rely on your memory to save you when you need to write everything down in your thesis! While you needn’t have everything written in final draft, having a detailed account of your research progress is a great idea. When you start your research, you and your advisor should try to establish a goal for your thesis as soon as possible. Performing research without a goal can be very difficult and even more frustrating.
When one does mathematical research, one rarely knows exactly where they are going. Gaining mathematical intuition comes from lots of hard work, not simply being very smart. A tried and true method for doing research is to do lots of examples, and make simplifying assumptions when needed. Before you can prove a theorem, you need a conjecture; these aren’t going to just fall in your lap! The idea is that after seeing enough examples, one can make a general conjecture and then hopefully prove it.
It’s a good idea to find out who else in the community (both in and out of the department) thinks about your field. You may find it useful to contact these people from time to time. This serves multiple purposes: you’ll lessen the chance of duplicating someone else’s research; you’ll find multiple sources of advice. While your advisor will likely be the single biggest source of help in writing your thesis, they needn’t be your only source. Talking to many people about your work will give you several different perspectives on the same thing. Seeing the same thing in different ways can be invaluable in understanding something.
When you have enough results such that you and your advisor are satisfied, you need to organize your work into one coherent document. This can be a highly non-trivial task! Make sure that your problem is stated clearly, along with why it is important, and how you solved it. Your thesis shouldn’t simply be a list of definitions, theorems, and proofs; there should be quite a bit of prose to explain the mathematical ambiance of your work. What is the motivation for even thinking about this problem? The more people that find your research interesting, the better.