The purpose of this paper is to investigate the role of government in innovation. That is, how much government invest in R\&D activity to enhance social welfare. An optimal control problem is proposed to answer above question. Because of difficulties in solving the problem, simulation was utilized to find an approximate solution. The decision variables of government are the ratio of capital and labor devoted to research activity. Government decides the ratio so as to maximize social welfare represented by aggregate consumption. All results obtained from the simulation are very similar. This guarantees the existence of solution. In the initial stage investment in R\&D activity increases and reaches its maximum and then decreases. R\&D investment is represented by the number of R\&D personnel and capital in research sector. An analysis was carried out according to the initial value. The results coincide with the intuition, that is, developing countries which are short of knowledge stock(low technology) need more investment in R\&D activity and more intense investment. The effect of efficiency in knowledge usage is same to increase of knowledge stock. It is also found that when the initial size of research sector is large, the investment in research activity should be more intense and larger.