Just throwing some things here.
This proof requires -
1. Handshaking Lemma (Degree Sum Formula) - It states, sum of degrees of all nodes in a graph is equal to twice the number of edges.
2. Tree is a connected graph with minimal edges, and as a consequence of this, a graph with $N$ nodes will have $N-1$ edges.
Now,
Sum of Degrees of all vertices $ = \left(1 \times l\right) + \left(3 \times D_2\right) + \left(2 \times D_1 \right) -1$
where,
1. $ \left( 1 \times l \right)$ - No. of leaf nodes is $l$ and leaf nodes have degree $1$.
2. $\left(3 \times D_2\right)$ - $D_2$ is no. of nodes with two children. The nodes with $2$ children will have degree of $3$, except for the root. The root will have $2$ children and no parent,hence degree will be $2$.
But we have considered root node in $D_2$, so we assumed degree $3$ for the root node, which is $1$ more than the actual degree $2$. Hence we have to subtract $1$, which is done in the end.
3. $\left(2 \times D_1\right)$ - Same as above, but here, no conflicts like root.