The problem of controllability of the dynamical state of a network is central in network theory and has wide applications ranging from network medicine to financial markets. The driver nodes of the network are the nodes that can bring the network to the desired dynamical state if an external signal is applied to them. Using the framework of structural controllability, here we show that the density of nodes with in-degree and out-degree equal to $0$, $1$ and $2$ determines the number of driver nodes of random networks. Moreover we show that networks with minimum in-degree and out-degree greater than 2, are always fully controllable by an infinitesimal fraction of driver nodes, regardless on the other properties of the degree distribution. Finally, based on these results, we propose an algorithm to improve the controllability of networks.