I don't understand why Kant didn't end the critique of pure reason with the transcendental dialectic. Why did he need this part of the text? What had been left unresolved after the transcendental dialectic?
I think the Transcendental Doctrine of Method ('TDM') fulfils two roles : (1) it introduces or reinforces certain contrasts Kant wants to make between philosophy and other subjects and to differentiate his approach to philosophy from a number of other approaches; and (2) it provides an anticipatory link with Kant's ideas about practical reason and ethics.
TDM's contrastive role
TDM has four chapters (excuse me for stating the obvious) :
Discipline of Pure Reason
Canon of Pure Reason
Architectonic of Pure Reason
History of Pure Reason
The Discipline sets out Kant's most developed views on the relation of philosophy to mathematics, stressing that both admit of synthetic a priori cognition but that mathematics can solve its problems definitively while philosophy can only define general principles and the conditions for the possibility of experience of objects. Mathematics can be determinate to a greater degree than is possible in philosophy.
The chapter then wanders off a bit into an argument for the freedom of public communication. I can't see that this really belongs.
Leave the second chapter for a minute. The third chapter, Architectonic of Pure Reason, continues the distinction between philosophy and other subjects, e.g. historical knowledge, and specifies in more detail the difference(s) between theoretical and practical reason.
The fourth chapter, History of Pure Reason, provides a high-level contrast between the transcendental philosophy of the Critique and dogmatism, empiricism, scepticism and indifferentism.
So chapters 1,3 and 4 serve to differentiate philosophy more thoroughly from other subjects and to mark off the Critical appproach from dogmatism, empiricism and the rest. Their principal role is contrastive.
TDM's anticipatory role
The second chapter, to return to that, the Canon of Pure Reason, makes the anticipatory link with practical reason and ethics. It 'contrasts the epistemological status of theoretical cognition with that of the principles and presuppositions of practical reason or morality, and in so doing provides Kant's most systematic discussion of moral philosophy prior to the Groundwork of the Metaphysics of Morals (1785) and Kant's first systematic statement of his argument for rational faith in God on moral grounds' (Guyer & Wood Introduction to I. Kant, Critique of Pure Reason, Cambridge : CUP, 1998, 19.)
It is hard to see what the argument for rational faith in God on moral grounds is doing here - to work out why Kant includes it - but the contrast between the epistemological status of theoretical cognition and that of the principles and presuppositions of practical reason fits with the general contrastive concerns of TDM. It also underlines that Kant has unfinished work to do on reason; he has to cover its practical side; it prepares us for the Groundwork and the Critique of Practical Reason as integral to the task of which the Critique of Pure Reason is only the first part and major component.
I have simply handled the text analytically as it stands. Philip Klöcking has kindly allowed me to cite the following material from his Comments to show that the history of the text has a crucial bearing on the TDM section :
Regarding the place of the Canon looking into Förster's The Twenty-Five Years of Philosophy (Harvard UP, 2012) proves helpful: He uses a lot of contemporary sources to argue that originally, Kant only planned a single critique, covering all of philosophy. This necessitates an argument for the full accord of theoretical and practical reason (thus forming a single "canon"), which he tried in this very section. Only because of Garve's critical comment that pointed out his petitio in this section he felt the need for a proper metaphysical foundation of ethics (and another critique).
This is also the reason why he sometimes calls the First Critique "critique of pure speculative reason" in later works, whereas the original work was named as it had been because it was meant to cover all critical endeavour. Obviously, both the according chapter in the Second Critique and huge parts of the Third Critique serve the aim of that very chapter in his later work: Arguing for the necessity of the accordance and coherence of theoretical/speculative and practical reason. Thus, the part relies on the premise that it is the only book needed and indeed appears strange in hindsight.
Guyer & Wood Introduction to I. Kant, Critique of Pure Reason, Cambridge : CUP, 1998.