Canvas graphics are stored in the canvas representation and accessed by clients such as the canvas view and canvas selections. The canvas representation owns its graphics and cannot guarantee that each of its graphics will always be at the same memory location. That is, when the representation is streamed out (when the document is closed) and later streamed in (when the document is reopened), all the canvas graphics in the representation when it was streamed out are still there, but at new memory locations. Therefore, clients of canvas representation use the unique ID as a reliable way to refer to graphics.
The unique ID is generated for a canvas graphic during construction. IDs can also be constructed by clients and explicitly set to a canvas graphic, when you need to replace one canvas graphic with another, but keep the same ID (such as in an undo or redo operation). You do not usually call SetID directly.