Coronaviruses are types of viruses that are widely spread in humans, birds, and other mammals, leading to hepatic, respiratory, neurologic, and enteric diseases. The disease is presently a pandemic with great medical, economical, and political impacts, and it is mostly spread through physical contact. To extinct the virus, keeping physical distance and taking vaccine are key. In this study, a dynamical transmission compartment model for coronavirus (COVID-19) is designed and rigorously analyzed using Routh–Hurwitz condition for the stability analysis. A global dynamics of mathematical formulation was investigated with the help of a constructed Lyapunov function. We further examined parameter sensitivities (local and global) to identify terms with greater impact or influence on the dynamics of the disease. Our approach is data driven to test the efficacy of the proposed model. The formulation was incorporated with available confirmed cases from January 22, 2020, to December 20, 2021, and parameterized using real-time series data that were collected on a daily basis for the first 705 days for fourteen countries, out of which the model was simulated using four selected countries: USA, Italy, South Africa, and Nigeria. A least square technique was adopted for the estimation of parameters. The simulated solutions of the model were analyzed using MAPLE-18 with Runge–Kutta–Felberg method (RKF45 solver). The model entrenched parameters analysis revealed that there are both disease-free and endemic equilibrium points. The solutions depicted that the free equilibrium point for COVID-19 is asymptotic locally stable, when the epidemiological reproduction number condition $$(R_{0}<1)$$
(
R
0
<
1
)
. The simulation results unveiled that the pandemic can be controlled if other control measures, such as face mask wearing in public areas and washing of hands, are combined with high level of compliance to physical distancing. Furthermore, an autonomous derivative equation for the five-dimensional deterministic was done with two control terms and constant rates for the pharmaceutical and non-pharmaceutical strategies. The Lagrangian and Hamilton were formulated to study the model optimal control existence, using Pontryagin’s Maximum Principle describing the optimal control terms. The designed objective functional reduced the intervention costs and infections. We concluded that the COVID-19 curve can be flattened through strict compliance to both pharmaceutical and non-pharmaceutical strategies. The more the compliance level to physical distance and taking of vaccine, the earlier the curve is flattened and the earlier the economy will be bounce-back.