The substance appears to be a rather fluent liquid. But in actuality, it's a viscous colloid of aqueous KMnO4 (potassium permanganate). The gel-like dispersion of this ionic solid throughout the water exponentially increases the water's cohesion (the H2O molecules stick to each other like a solid while remaining in the liquid state). Look up colligative properties.

The "firmer" substance retains the shape of the glass because the structure wants to minimize its free energy. It's easier for it to stay in shape than to settle out due to the water's cohesion. However, a slight disturbance will cause it to change state and *snap* it settles.