In a previous post I complained that the push to solar panels on rooftops didn't make a lot of economic sense. This is part of a more general problem, you have to be careful when comparing different methods of generating electricity.
Because the demand for electrical power varies over time and because there is no really good way currently known to store electrical power the system has to able to vary generator output to match demand. This means generators that can be throttled to generate power as needed are superior to generators whose power output varies depending on external factors not under the control of the operator. Therefore it can be misleading to compare electrical generation methods just based on cost per kwh as not all kwh are equally valuable.
Unfortunately wind and solar panel power generators fall into the less valuable category whose output varies outside the control of the operator. This means they are not as competitive with fossil fuel generators as they might seem just based on per kwh cost. This effect will become worse as wind and solar panel power account for a greater fraction of total power generated since the remainder of the system will have to accommodate greater swings in demand.
Now these problems are not insurmountable. Power can be stored albeit at considerable cost. However switching away from fossil fuel generators is not going to be easy or cheap.