This paper presents a novel virtual inertia controller for converters in power systems with high share of renewable resources. By combining the analytical study of system dynamics and a Linear-Quadratic Regulator (LQR)-based optimization technique, the optimal state feedback gain is determined, adapting the emulated inertia constant according to the frequency disturbance in the system. The optimality is achieved through trade-off between the critical frequency limits and the required control effort, i.e. utilization of the internal energy storage. The proposed controller is integrated into a state-of-the-art converter control scheme and verified through EMT simulations. The results show a significant improvement in the frequency response compared to an open-loop system, while also preserving drastically more DC-side energy than a non-adaptive controller.