Riboswitches are non-coding RNA that regulate gene expression by folding into specific three-dimensional structures (holo-form) upon binding by their cognate ligand in the presence of Mg2+. Riboswitch functioning is also hypothesized to be under kinetic control requiring large cognate ligand concentrations. We ask the question under thermodynamic conditions, can the riboswitches populate holo-form like structures in the absence of their cognate ligands only in the presence of Mg2+. We addressed this question using thiamine pyrophosphate (TPP) riboswitch as a model system and computer simulations using a coarse-grained model for RNA. The folding free energy surface (FES) shows that with the initial increase in Mg2+ concentration ([Mg2+]), TPP AD undergoes a barrierless collapse in its dimensions. On further increase in [Mg2+], intermediates separated by barriers appear on the FES, and one of the intermediates has a TPP ligand-binding competent structure. We show that site-specific binding of the Mg2+ aids in the formation of tertiary contacts. For [Mg2+] greater than physiological concentration, AD folds into its holo-form like structure even in the absence of the TPP ligand. The folding kinetics shows that it populates an intermediate due to the misalignment of the two arms in the TPP AD, which acts as a kinetic trap leading to larger folding timescales. The predictions of the intermediate structures from the simulations are amenable for experimental verification.